Jul 09

Literals are nothing but pieces of Java code that indicate explicit values.

The following table shows all types of literals :

Type of literal

Example

Number In decimal system :  allow digits from 0 through 9.

for example : 25 , -34 , 66 , etc.

In octal system :  allow digits from 0 through 7.

for example : 025 ,032 , etc.

In hexadecimal system :  allow digits from 0 through 9 and letters from A to F.

for example :  0×34 , 0×21 , etc.

Long 34L , -45L , 33L , etc.
Float 45.6f , -34.6f , 45.78e3f , etc.
Double 1.5 , 45.6 , 45.7e32 , etc.
String ” Java is case sensitive “
Character ‘a’ , ‘4′ , ‘t’ , etc.
Boolean true or false
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • LinkedIn
  • MySpace
  • Reddit
  • RSS
  • Twitter

written by Anup