3.3. Elementare Typen
Typ | Bit-Tiefe | Wertebereich |
boolean und char
boolean | (JVM-specifisch) | true oder false |
char | 16 Bit | bis 65535 |
numerisch (alle vorzeichenbehaftet)
Ganzzahlen
byte | 8 Bit | -128 bis 127 |
short | 16 Bit | -32768 bis 32767 |
int | 32 Bit | -2147483648 bis 2147483647 |
long | 64 Bit | -gewaltig bis gewaltig |
Fließkommazahlen
float | 32 Bit | variabel |
double | 64 Bit | variabel |
Deklarationen von elementaren Typen mit Zuweisung:
int x; x = 234; byte b = 89; boolean machtSpaß = true; double d = 3456.98; char c = 'f'; int z = x; boolean isPunkRock; isPunkRock = false; boolean lichtAn; lichtAn = machtSpaß; long big = 3456789; float f = 32.5f;
Achten Sie auf das »f«. Bei einem float-Wert brauchen Sie das, weil Java denkt, dass alles mit einem Dezimaltrenner ein double ist, wenn ihm nicht ...
Get Java™ von Kopf bis Fuß now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.