Basic Java Language: Difference between revisions
wikademia>Cremisis13 |
|||
| Line 47: | Line 47: | ||
</center> | </center> | ||
=Statements= | =Statements= | ||
All calculations are done in statements. Every | All calculations are done in statements. Every statement ends in a semicolon: ;. Statements can set a variable with the '=' operator. This sets the variable you wish to set to another variable or a value. Values can only be used on primitive types. As you saw in the HelloWorld program, there was one statement: <code>System.out.println("Hello, World")</code>. This is one type of statement called calling a method. More will be discussed later. Finally, you can declare a variable. If a class has no statements, it would do nothing. | ||
=Variables= | =Variables= | ||
Variables Variables are used to store data into your computer memory, that can change. All you need to worry about is that you can create a variable and change its value. 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 "int" or "String". | Variables Variables are used to store data into your computer memory, that can change. All you need to worry about is that you can create a variable and change its value. 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 "int" or "String". | ||