JAVATM- The Beginnings


A literal is a symbol we use to represent a constant value.

When we place  the literal 5 in a Java source file

X = 5;

      the Java compiler substitutes the symbol 5 with the whole number value 5.

Section 1 - Integer Literals

Java assumes all integer literal are of type int (32 bits).


Append the letter L to an integer literal to indicate it should be treated as a long integer (64 bits):


Section 1a - Integer Literals in Different Numeric Bases

The literal for the number 15 can be displayed in the following form.

binary form:             0b1111               <- prefixed by 0b

octal form:               017                     <- prefixed by 0

hexadecimal form:   0xF                    <- prefixed by 0x

Section 2 - Floating Point Literals

Java assumes all floating point literals are of type double (64 bits).


Copyright ©2017 by Ralph Lecessi Incorporated. All rights reserved.

Back to