Posts

Showing posts with the label Boolean

Char and Boolean Data Types in Java and Kotlin with Examples

Table of Contents Introduction Char Data Type Boolean Data Type Java vs Kotlin Differences Interview Questions Conclusion Introduction Char and Boolean are fundamental data types used for representing characters and logical values. Both Java and Kotlin support these types with small but important differences in syntax and safety. 1. Char Data Type The Char data type is used to store a single Unicode character such as letters, digits, or symbols. Memory Size: 16 bits Represents Unicode characters Written using single quotes ( 'A' ) Char Example Overview Feature Java Kotlin Keyword char Char Unicode Support Yes Yes Numeric Operations Allowed Not Allowed Kotlin Example val letter: Char = 'A' println(letter) Java Example char letter = 'A'; System.out.println(letter); 2. Boolean Data Type The Boolean data type is used to store true or false values. It is commonly used in condi...