Data encoding
- Primitive datatypes in
Java
are:
char
that represents unicode character and are encoded with 2 octects, eg. char c='X';
int
encoded with 4 octets and that corresponds to integers with:
- arithmetic operators (+,-,/,%) and
- relational operators (==,!=,<,<=...)
long
are also integer values but use 8 octets.
float
that represents real numbers and are encoded with 4 octets, e.g. float pi=3.13F;
double
that represents double precision real numbers and are encoded with 8 octets
byte
that corresponds to 1 octet
boolean
represents true/false values and are encoded with 1 octet
- 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
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented