Friday, May 23, 2008

Non-Numerical Literals

Non-Numerical Literals

There are two major non-numerical literals in Java. The first, a character literal, represents a single character surrounded by quotations. Some characters are not so obvious or simply cannot be encased in quotations. That is where character escapes come in. The following post is a list of commonly used escape characters to print the not-so –obvious values:

Tuesday, May 20, 2008

Literals Notes 2

Literals Notes 2

Floating-point types also let you specify scientific notation by using the letter e or (E) to represent the exponential power. For example, the value 2.54 x 10 power 5 represented in Java is 2.54e5 or 2.54e5f housed in the float type.

Unlike C and C ++, Java has Booleans literals, Java Booleans represent either the non-numerical value true or false.

Monday, May 19, 2008

Literals Notes

Appended letters for specifying a particular data type when using literals are not case sensitive. For example, 100001 and 10000L both specify this literal to be a numerical type long. Extremely large values utilize the integer data type long. Floating-point values are automatically assumed to be a type double. However if you wish to use the smaller floating-point type float, then you need to append a letter “f” to represent that data type 2.313f.

Sunday, May 18, 2008

Numerical Literals

In Java programs, numerical literals represent quantitative values, Java supports several different numerical systems, including octal (a numbering system with a base of 8) and hexadecimal (using a base of 16). If needed, you can specify the literal to be long by appending the letter “L”: 24050000L. An int is the default type used for integer literals.

Thursday, May 15, 2008

Literal 2

Literal 2

Data types, discussed later in the chapter are values (a.k.a variables) that represent or hold other values. This is very similar to algebra, where x can be more than just x; x could be 2, square root of -5, or the gross national product. As you will learn later, Java has a specific set of data types for certain values.

Monday, May 12, 2008

Literal

Literal

A literal is any value expressed as itself. There are several types of literals; numerical literals, including integers, floating-point values, and Booleans; and non-numerical literals, including characters and multiple literals (known as string literals).

Sunday, May 11, 2008

Getting A First Sip In Java

For a moment, let’s leave the theoretical world behind and get our hands dirty with Visual J++ by creating a very simple Java program in Visual J++.

To create any program in Visual J++, follow these 3 simple steps:

Write the program. (Later on you will learn tips and tricks to let Visual J++ write parts of your programs for you.)
Compile or build the code into an executable format.
Execute program.