Archive | Java Tutorials

Tags: , , , , , ,

Java Programing Language: Using Underscore Characters in Numeric Literals

Posted on 01 June 2012 by Moki

In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example. to separate groups of digits in numeric literals, which can improve the readability of your code. For instance, if your code contains numbers with many digits, you can [...]

Comments (0)

Tags: , , , , , , , ,

Java Programing Language: What are “Character and String Literals”?

Posted on 01 June 2012 by Moki

Literals of types char and String may contain any Unicode (UTF-16) characters. If your editor and file system allow it, you can use such characters directly in your code. If not, you can use a “Unicode escape” such as ‘\u0108′ (capital C with circumflex), or “S\u00ED Se\u00F1or” (Sí Señor in Spanish). Always use ‘single quotes’ [...]

Comments (0)

Tags: , , , , , ,

Java Programing Language: What are “Floating-Point Literals”?

Posted on 01 June 2012 by Moki

A floating-point literal is of type float if it ends with the letter F or f; otherwise its type is double and it can optionally end with the letter D or d. The floating point types (float and double) can also be expressed using E or e (for scientific notation), F or f (32-bit float [...]

Comments (0)

Tags: , , , , , , , ,

Java Programing Language: What are “Integer Literals”?

Posted on 01 June 2012 by Moki

An integer literal is of type long if it ends with the letter L or l; otherwise it is of type int. It is recommended that you use the upper case letter L because the lower case letter l is hard to distinguish from the digit 1. Values of the integral types byte, short, int, [...]

Comments (0)

Tags: , , , , , , ,

Java Programing Language: What are “Literals”?

Posted on 01 June 2012 by Moki

You may have noticed that the new keyword isn’t used when initializing a variable of a primitive type. Primitive types are special data types built into the language; they are not objects created from a class. A literal is the source code representation of a fixed value; literals are represented directly in your code without [...]

Comments (0)

Tags: , , , , , , , , , , , , , ,

Java Programing Language: 8 Primitive Data Types

Posted on 01 June 2012 by Moki

byte: The byte data type is an 8-bit signed two’s complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where [...]

Comments (0)