Saturday, 4 August 2007

Java Language Fundamentals (Part 7)

Language Fundamentals


Data Types - cont

Integrals & floats

The following table gives the length of integrals and floats






























Name or TypeLength
byte8 bits
short16 bits
int32 bits
long64 bits
float32 bits
double64 bits

Note! Floating
point literals are double unless explicitly
declared as type float


The following is an example of a various declarations


public class
ExampleDeclarations{


public static
void main(String args[]){


int
topSpeed = 150;


float
gear1Change = 25.09F;


double
gear2Change = 48.98;


boolean
goFast = true;


char
myCharacter = ‘R’;


String
errorMessage = “You made a boo boo!”;


}


}



No comments:

Post a Comment