Integers
• Signed 32-bit integer, range: -2,147,483,648 to 2,147,483,647
• Use the int keyword to declare an integer variable
Floats
• IEEE 754 floating-point number, 32-bit
• Use the float keyword to declare a float variable
• Suffix with f or F to indicate a float literal
Binary, Hexadecimal, and Octal
• Binary: 0b or 0B followed by a binary number
• Hexadecimal: 0x or 0X followed by a hexadecimal number
• Octal: 0 followed by a octal number
Arbitrarily Large Numbers
• Java uses BigInteger and BigDecimal classes to handle large numbers
• These classes can be found in the java.math package
Underscore in Numeric Literals
• Numeric literals can contain underscores to improve readability
• However, underscores cannot appear at the beginning or end of the literal
• Underscores are not allowed in the decimal point
The 'E' and 'Epsilon' Notations
, • Floating-point numbers can use scientific notation with the 'E' notation
• The 'E' stands for exponent and is followed by the exponent value
• The 'epsilon' notation is used as a tolerance value in floating -point
calculations
Boolean Data Type
• Represents true or false values
• Use the boolean keyword to declare a boolean variable
• The boolean values are: true and false
Character and String Literals in Java
Character Literals
• Enclosed in single quotes ( ' )
• Represent a single character
• Can include escape sequences (e.g. \n for newline)
String Literals
• Enclosed in double quotes ( " )
• Represent a sequence of characters
• Can include escape sequences (e.g. \t for tab)
Arbitrarily Large Numbers and Java's
Implementation
• Java uses a system called automatic garbage collection