how are decimal octal and hexadecimal integer literals represented in java?
Answers
Answer:
Java has several integer literals. The number 4, for example, is an integer literal of the int variable type. It also can be assigned to byte and short variables because the number is small enough to fit into those integer types. An integer literal larger than an int can hold is automatically considered to be of the type long. You also can indicate that a literal should be a long integer by adding the letter L (L or l) to the number. For example, the following statement treats the value 4 as a long integer:
pennyTotal = pennyTotal + 4L;
To represent a negative number as a literal, prepend a minus sign (-) to the literal, as in -45.
If you need to use a literal integer with octal numbering, prepend a 0 to the number. For example, the octal number 777 would be the literal 0777. Hexadecimal integers are used as literals by prepending the number with 0x, as in 0x12 or 0xFF