Java Keywords
List of Java Keywords
Primitives DataTypes : byte,short,int,long,float,double,char,boolean
Flow Control : if, else,for,do, while, switch, case, default, break, continue,return
Exception Handling : try, catch, finally,throw,throws,assert
Modifiers : public,private,protected,final,static,native,abstract,
synchronized,transient,volatile,strictfp
Class Related : class,interface,package,extends,implements,import
Object Related : new, instanceof,super,this
Literals : true, false, null
Others : void, enum
Unused : goto,const
Literals
Any primitive data type value in source code is called Literal.
There are four types of literals:
Integer & Long
Floating Point
Boolean
Double
Literals
Integer Literals
There are 3 ways of representing an Integer Literal.
Decimal. Examples: 343, 545
Octal. Digits 0 to 7. Place 0 before a number. Examples : 070,011
Hexadecimal. Digits 0 to 9 and alphabets A to F (10-15). Case insensitive.
An integer literal by default is int.
Long Literals
All 3 integer formats: Decimal, Octal and Hexadecimal can be used to represent long by
appending with L or l.
Floating point Literals
Numbers with decimal points. Example: double d = 123.456;
To declare a float, append f. Example: float f = 123.456f;
Floating point literals are double by default.
Appending d or D at end of double literal is optional Example: double d = 123.456D;
Boolean Literals
Valid boolean values are true and false.
TRUE, FALSE or True, False are invalid.