Friday, December 6, 2013

java primitive type

Data Type Default Value (for fields)
byte  8-bit signed integer 0
short  16-bit signed integer 0
int  32-bit signed integer 0
long 64-bit singed integer 0L
float 32-bit floating point 0.0f
double 64-bit floating point 0.0d
char 16-bit Unicode character '\u0000'
String (or any object)   null
boolean  two possible values false




Literal: To describe something as literal is to say that it is exactly what it seems to be.


Literals  ( = contants )

You may have noticed that the new keyword isn't used when initializing a variable of a primitive type. Primitive types are special data types built into the language; they are not objects created from a class. A literal is the source code representation of a fixed value; literals are represented directly in your code without requiring computation. As shown below, it's possible to assign a literal to a variable of a primitive type:
boolean result = true;
char capitalC = 'C';
byte b = 100;
short s = 10000;
int i = 100000;


No comments:

Post a Comment