Monday, June 22, 2009

Java Literals

Literals are signs that the changes do not occur or constant. Different literals in Java is: Integer Literals, Floating-Point Literals, Boolean Literals, Character Literals and String Literals.

Integer Literals

Integer literals be distinguished in several different formats: decimal (base 10), hexadecimal (base 16), and octal (base 8). In the use of data type integer on the program, we must follow the rules of some special notation.
For decimal numbers, we do not need a special notation. We only write the number as a decimal is. for hexadecimal digits, it must be marked by "0x" or "0x". for octal, marked by "0". For example, a number representing 12. Writing in the form of desimalnya is 12, Meanwhile, in hexadecimal, it becomes 0xC, and in octal, with the same value 014.
Default data type for integer literals is int. Int is a signed 32-bit value. In the cases you can expect to force integer literal to be long data types by adding the characters "l" or "L". data types are marked by long displaying data in 64-bit. We will discuss the types of data on
next opportunity.

Floating-Point Literals

Floating point literals represent decimal form with a separate section. As example is 3.1415. Floating point literals can be expressed in standard notation or scientific. For example, 583.45 stated in the standard notation, while 5.8345e2 expressed in scientific notation.
Default Floating point literals have the type of data that is expressed in the double 64-bit. To use the accuracy of smaller (32-bit) float, only to add character "f" or "F".

Boolean Literals

Boolean literals have only two values, true or false.

Character Literals

Character Literals represented by a single Unicode character. Unicode characters are 16-bit character set that replaces the 8-bit ASCII character set. Unicode allows use of symbols and special characters from other languages.
To use character literals, the characters in the single pute marks ( '') (single quote delimiters). For example a letter, represented as' a '.
To use special characters such as a new line character, backslash is used followed by the character code. For example, '\ n' character to a new line or replace the line, '\ r' to represent the value back (carriage return), '\ b' Backspace to.

String Literals

String literals represent multiple characters and expressed in double pute marks ( "") ( double quotes). For example the string literal is, "Hello World".

No comments:

Post a Comment