Sunday, 9 March 2014

Literals

Literals represent a value that is stored in variables directly in the program.For example 
int x=234;
here values in the right side are called literals because these values are stored in the variables in the left side.As we have discussed earlier that there are different data types.So there are following types of Literals-

  • Integer Literals
  • Float Literals
  • Character Literals
  • String Literals
  • Boolean Literals 
Integer Literals
It represents fixed integer values like 100,22,33.For example
int x=34;
Float Literals
It represents fractional numbers like 22.456, 32.006.For example
float c=44.66f;
Character Literals
It represents character values like a,b,B,'D'.for example
char ch='A';
String Literals
It represents String values like "hello","Anil".for example
String s1="Hello";
Boolean Literals 
It represents only two values either true or false



In next blog we will discuss about Operators in Java

 

No comments:

Post a Comment