Jul 09

Data types specify the size and type of values that can be stored.

Data types are categorised as :

  • Primitive types (also called intrinsic or built-in types)
  • Non-Primitive types ( also called derived types)


Primitive types

Data Type

Group Size(in bits) Default Value Range Example
byte Integer 8 0 -128 to 127 10 , 24
short 16 0 -32768 to 32767 500 , 786
int 32 0 -2147483648 to 2147483647 89,945 , 37865
long 64 0 -9223372036854775808 to 9223372036854775807 78L , -650L
float Floating point numbers 32 0.0 -1.4e-45 to 3.4e+38 78.5f , -68.0f
double 64 0.0 -4.9e-324 to 1.7e+308 56.25 , 5. , .67
char Characters 16 \u0000 \u0000 to \uFFFF ‘r’ , ‘>’ , ‘=’
boolean Boolean 1 bit used in 32 bit integer false not applicable true or false

Non-Primitive types

  • It includes types which are composed of primitive types.
  • Reference types,arrays,enum,interfaces all come under this category.
  • The default value of reference types is null.

An important non-primitive type provided by Java language is String.

Here, String is a class used to hold set of characters within double quotes.

String objects are immutable, means once initialized their values cannot be altered.


Use of String type

StringĀ  str=” Java is platform independent ” ;

since it is immutable, the content of str cannot be changed.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • LinkedIn
  • MySpace
  • Reddit
  • RSS
  • Twitter

written by Anup