OO Programming with Java


Data encoding

  1. Primitive datatypes in Java are:
  1. All the primitive datatype are associated to a corresponding class called wrapper for the type, e.g. Char for char, Integer for int, etc. The classes then propose all program to manipulate the primitive value as illustrated below:
String  str = Integer.toString( 12 );
int     val = Integer.parseInt(str);
Integer obj = Integer.valueOf(val);
System.out.println(obj.compareTo(new Integer(1)));
// -1 = inferior, 0 = equal, 1 = superior