how many types of integer constant are allowed in java ? how are they are written
Answers
Explanation:
In Java, a constant value is created by using a literal representation of it. For example, below are some literals :
100 - specifies an integer literal
98.6 - specifies a floating-point literal
'X' - specifies a character constant
"This is a test" - this literal specifies a string literal
A literal can be used anywhere a value of its type is allowed.
Types of Literals
In Java, there are the following types of literals:
Integer Literals
Floating-point Literals
Boolean Literals
Character Literals
String Literals
Three types
Java Hexadecimal Integer Literals
Therefore the number 12 will be written either as 12 (as decimal) or 14 (as octal) or 0XC (as hexadecimal). To convert a number from any number system to Hexadecimal Number System, check the following : Java Decimal to Hexadecimal Conversion.