Java Data Types Cheat Sheet
Java Data Types Cheat Sheet
float Can hold up to six significant No commas, but can have a float weight = 123.5f;
decimal digits. For more decimal point. Must end with f.
A float is a number that can have
digits, use double.
a fraction. .123456f
98.6f
1000000.f
0f
double Can hold up to 15 significant No commas, but can have a double interestRate =
3.000025;
decimal digits. decimal point. If no decimal
A double is a number that can
point, must end with d.
have a fraction. Use it when you
need more digits than a float can .123456789012345
66.66667
hold. 1000000000.
0d
char A char value comes from the Surround with single quotes. char myInitial = 'A';
Unicode character set.
A char is a single character, no 'A' // uppercase
more and no less. letter A
' ' // a space
*Code samples are licensed under the Apache 2.0 License. All other content is licensed under the Creative Commons Attribution 3.0 License.