What is the difference between data types and literals in Java?
Int (Data type) x (Variable) = 100 (Literals) ;
Data type :- Data type means type of data ,it may be byte
, short
, int
, long
, float
, double
,char
boolean
and many other user defined type(Class) like Employee, Student etc...
Literals :- The value we assign to variable is called Literal .
e.g:- String str= "India";
Here "india" is string Literal .
Literals are fixed value for a variable until they are not assign by other variable.
true
, false
and null
are reserved word in java. Technically they are literals values and not keywords .However they can not be used as Identifier because they have specific meaning to the java Compiler.