Language Fundamentals
Data Types - cont
Integrals & floats
The following table gives the length of integrals and floats
Name or Type | Length |
byte | 8 bits |
short | 16 bits |
int | 32 bits |
long | 64 bits |
float | 32 bits |
double | 64 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