Literals in Java Simplified

Literals in Java
Literals in Java

Literals in Java Simplified:

In general when we insert a literal value into a program the compiler knows what type to make it.However if the type is ambiguous,we need to provide compiler some more information about it and guide it in the form of characters associated with the literal value.



Hexadecimal(base-16) is denoted by leading ox or OX followed by 0 to 9 and a-f either in upper case or lower case Exp-ox7fff


Octal (base-8) is denoted by a leading zero and digits from 0 to 7.


Binary has no representation except 0 and 1.

A training character after a literal is its l/L stand for long,D/d stand for double,f/F stands for float.If we try to initialize a variable with a value bigger than it can hold,the compiler will provide an error message or it will automatically makes a bigger datatype and ask us to narrow it for assignment. To convert a lower capacity data type to higher capacity is called promotion.
In an operation,where two different types of data are present , the resultant automatically get promoted to max of the two data type.
Literals in Java Simplified Literals in Java Simplified Reviewed by Animesh Chatterjee on December 27, 2018 Rating: 5

No comments:

Powered by Blogger.