Professional Documents
Culture Documents
DATA TYPE
A data type is characterized by:
a set of values a data representation, which is common to all these values and a set of operations, which can be applied uniformly to all these values.
TYPE NAME
Byte Short Int Long Float Double Char Boolean
KIND OF VALUE MEMORY USED Integer Integer Integer integer floating point number floating point number single character true or false 1 byte 2 bytes 4 bytes 8 bytes 4 bytes 8 bytes 2 bytes 1 bit
SIZE RANGE
-128 to 127 -32768 to 32767 -2147483648 to 2147483647 -9223372036854775808 to 9223372036854775807 3.40282347x1038 to 1.40239846x1045 1.76769313486231570 to 4.94065645841246544x10324 all Unicode character Not applicable
Integers
- An integer that is stored w/ a sign is called signed numbers; an integer that isnt stored w/ a sign is called unsigned numbers. An unsigned integer is a value that is implied to be positive. The positive sign is not stored in memory. All integers in Java are represented w/ a sign. Zero is stored as a positive number.
Floating Point
- used to store real numbers in memory. A real number contains a decimal value. - Refers to the way decimals are referenced in memory.
2 Kinds of Floating Point : float- is a single precision number double- is a double precision number Precision of a number is the number of places after the decimal point that contains an accurate value. 2 Parts of a Floating-Point number: a. the real number-w/c is stored as a whole number b. the position of the decimal point within the whole number
Characters
- is represented as an integer value that corresponds to a character set - A character set assigns an integer value to each character, punctuation, and symbol used in language. - Choose a char whenever you need to store a single character in memory. - It reserves 16 bits of main memory.
Boolean
- reserves memory to store a boolean value, w/c is a true or false represented as a 0 or 1. - Choose a boolean whenever you need to store one of two possibilities in memory. - It reserves 1 bit of main memory.
Classes in Java
A class defines a data type The possible values of a class are called objects The operations on the objects are called methods The data representation is all the fields that are contained within the object If there is no external access to the data representation, you have an abstract data type Suns Java classes are (almost all) abstract data types
ADTs
List Queues Stacks Trees String Map Set