Basic Java Language: Difference between revisions
Appearance
wikademia>Crossbow9 No edit summary |
wikademia>Crossbow9 No edit summary |
||
| Line 1: | Line 1: | ||
This lesson discusses the basics of the Java language, including variables, primitives, operators, statements and Java writing conventions. | |||
==Variables== | |||
Variables are used to store data that can change. There are two main categories of variables, ''reference variables'' and ''primitive variables''. Reference variables are place holders for objects (More on objects in Lesson 4, [[Java Objects and Classes]].) Primitive variables are given a value of a primitive, a basic value. Variables are all given a type when they are declared, such as "integer" or "string". | |||
==Primitive Data Types== | |||
Primitives are the simplest type of data. Primitives consist of numbers, letters and strings of letters. The following table shows all the types of primitives. | |||
<center> | |||
{| border=1 cellspacing=0 cellpadding=5 | |||
| '''Primitive''' | |||
| '''Description''' | |||
| '''Values''' | |||
|- | |||
| byte | |||
| A brief, 8-bit integer | |||
| Whole numbers -128 through 127 | |||
|- | |||
| short | |||
| A short, 16-bit integer | |||
| Whole numbers -32,768 through 32,767 | |||
|- | |||
| int | |||
| A 32 bit integer | |||
| Whole numbers -2,147,483,648 through 2,147,483,647 | |||
|- | |||
| long | |||
| A long, 64 bit integer | |||
| Whole numbers -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807 | |||
|- | |||
| float | |||
|} | |||
</center> | |||
[[Topic:Java|Back]] | [[Topic:Java|Back]] | ||
Revision as of 02:35, 25 September 2006
This lesson discusses the basics of the Java language, including variables, primitives, operators, statements and Java writing conventions.
Variables
Variables are used to store data that can change. There are two main categories of variables, reference variables and primitive variables. Reference variables are place holders for objects (More on objects in Lesson 4, Java Objects and Classes.) Primitive variables are given a value of a primitive, a basic value. Variables are all given a type when they are declared, such as "integer" or "string".
Primitive Data Types
Primitives are the simplest type of data. Primitives consist of numbers, letters and strings of letters. The following table shows all the types of primitives.
| Primitive | Description | Values |
| byte | A brief, 8-bit integer | Whole numbers -128 through 127 |
| short | A short, 16-bit integer | Whole numbers -32,768 through 32,767 |
| int | A 32 bit integer | Whole numbers -2,147,483,648 through 2,147,483,647 |
| long | A long, 64 bit integer | Whole numbers -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807 |
| float |