Literals

Literals Description Example
Integer Literal Represents a whole number without a fractional part. int count = 10;
Floating-point Literal Represents a decimal number with a fractional part. double pi = 3.14;
Boolean Literal Represents a logical value of true or false. boolean isStudent = true;
Character Literal Represents a single character enclosed in single quotes. char grade = 'A';
String Literal Represents a sequence of characters enclosed in double quotes. String name = "John Smith";
Null Literal Represents the absence of any value. String text = null;
Hexadecimal Literal Represents an integer value in hexadecimal (base 16) format. int number = 0xFF;
Octal Literal Represents an integer value in octal (base 8) format. int flags = 012;
Binary Literal Represents an integer value in binary (base 2) format. int mask = 0b1010;
Prev‹

Post a Comment

Previous Post Next Post