Monday, February 25, 2008

ICA-ICP Info: Java Primitive Data Types

First of all, we have some great reference web sites for Java data type info:

Data types explained at the Java tutorial web site
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html

From another Java tutorial web site called Cafe Au Lait:
http://www.cafeaulait.org/course/week2/02.html

Info on Java data types:
1) There are built-in data types in Java called primitive data types. Primitive data types include boolean, byte, int, double, and char.
2) There are also additional data types in Java called abstract data types. Abstract data types include String and KeyboardReader.
3) A bit is a 1 or a zero. A byte is 8 bits.
4) boolean: The size is 1 bit. The value is 1 or zero. 1 is true, and zero is false.
5) byte: The size is 8 bits. The value range is -128 to 127. 7 bits are data, and 1 bit is for the + or - sign.
6) int: The size is 4 bytes or 32 bits. The value range is -2,147,483,648 to 2,147,483,647. One bit is for the + or - sign, and 31 bits are data.
7) double: The size is 8 bytes or 64 bits. The value range is 4.94065645841246544e-324d to 1.79769313486231570e+308d.
8) char: The size is 2 bytes or 16 bits. The value range is zero to 0 to 65,535. It uses Unicode, which is a giant lookup table which assigns a character to one of the numbers, to represent the characters.
9) Casting in Java changes one data type to another. A general rule of thumb is that it is safe to cast a smaller sized data type to a larger one, like and int to a double.

0 Comments:

Post a Comment

<< Home