|
Primitive Data Types | Size (in bits) | Range | | | | | Boolean | 8 | 0 to 2^16-1 | Char | 16 | 0 to 2^16-1 | Byte | 8 | -2^7 to 2^7-1 | Short | 16 | -2^15 to 2^15-1 | Int | 32 | -2^31 to 2^31-1 | Long | 64 | -2^63 to 2^63-1 | Float | 32 | | Double | 64 | |
Signed Integral Data Type: Byte (-2^7 to 2^7-1) Short (-2^15 to 2^15-1) Int (-2^31 to 2^31-1) long (-2^63 to 2^63-1) Floating Point Types: float double Literals: 1) A literal is a value that may be assigned to a primitive or string variable or passed as an argument to a method call. 2) Using a literal representation of it creates a constant value in java. Boolean Literals 1. true boolean isBig = true; 2. false boolean isLittle = false; String literals 1) A string literal is a run of text enclosed in double quotes. String s = " This is a String Literal. "; Char Literals 1) Java characters are in Unicode, which is a 16- bit encoding. 2) A char literal can be expressed by enclosing the desired character in single quotes: char c = 'w'; 3) Java supports a few escape sequences for denoting special characters. E.g. '\n' for new line. Integral literals 1) Integral literals may be expressed in decimal, octal or hexadecimal. E.g. 28, 0.34, 0*1c Floating-point literals 2) A floating point literal expresses a floating-point numerical value. e.g. 1.414, 4.2E+21, 1.828f, 1234d White space 3) Space, tab or newline. Separators ( ) { } [ ] ; , . Parentheses braces brackets semi-colon comma period
|