Computer program, written in any programming language, basically made of 3 elements: data, operating data, and logic that define the operation. Therefore, to manipulate the data (and operate holding him) are the core of the program kompouter typikal. Data held by the variables and operations are made using the service. Data held by the program may come with a different type, such as integer or character.
Understanding variable, data type, and Operator
Each item of data in the computer program has such as the type of character or integer. Because there are 2 kinds of data types, primitive (basic) and nonprimitive (advanced), there are 2 kinds of variables related: primitive variables, which are usually only called variables, and variable reference, which is also called a reference object. As shown in the image 2.1, the variable value for the primitive holds primitive data type, such as integer values, while a reference variable holds a reference to the object dimanasaja stored in the memory. For example, student ID can be represented by the primitive variable with the type of primitive int and the object of the class students can be represented by the reference variables, such as arsy, which refers to the actual object from the class of students.
As mentioned, items such as primitive data from students from id int type stored in the memory, which is shown as a variable (a variable primitive). The value stored in the variables can be changed. Variables can only hold specific data, called the data type. You need to specify the type of data when you recognized variables. For example: recognized variables, including named variables and specify the type of data, as follows:
Kode ini dengan mendeklarasikan sebuah variabel, meminta alokasi memori untuk menyimpan sebuah angka integer, dan memori akan dirujuknya menggunakan nama variabel id. Sebagai contoh, kita akan menyimpan angka 9 pada bagian memori dengan kode berikut ini:
id = 9
Here, symbol = is an example of one type of service, which is called the assignment operator. Variable name is called en identifier.
Variable name: the Legal Identifier
Every variable has a name, given by the programmer when the variables are recognized. This name is called identifier. Under these rules is to designate a variable:
* Characters from the first identifier must be a letter, a dollar sign ($), or a sign underscores (_).
* A character other than the characters in the first identifier may be a letter, a dollar sign, an underscore, or numbers.
* There is no Java language keyword (reserved words) can be used as an identifier.
So, variabelmu named by the first two rules, and do not use the name reserved because it will make illegal identifier. Here are some examples of legal and illegal identifier.
* 4buku: This identifier is illegal because the first characters of the identifier that the letter must be invalid, a dollar sign, or an underscore, not numbers.
* 110 # weight: This is the identifier that illegal because of the # sign. Characters that allowed only a dollar sign, an underscore, numbers and letters.
* $ __420_harga: This identifier is also illegal. Compare this to the rules on the previous list.
Name-Name had been provided: Keyword
Java keyword is a word that has been provided in the Java language. Each keyword has a special meaning in the language. Therefore, a programmer can not use these words to designate the variables, class-class, or methods. For example, the word int keyword is used to recognized that bertipe integer variables. Below is a list of keywords Java:
abstract const final int public
assert continue finally interface return
boolean default float long short
break do for native static
byte double goto new strictfp
case else if null super
catch enum implements package switch
char extends import private synchronized
class false instanceof protected this
throw throws transient true try
void volatile while
Here are a few points to remember about the keyword:
* Keyword use only letters; they do not use special characters (such as $, _, etc.) or numbers.
* All keyword in small letters
* Exercise for careful keyword derived from languages other than Java, such as a friend, include, and unsigned, that is not the keyword in the Java language.
* Word and goto const is provided to the extent that programmers can not gnakan, but they do not have a special meaning in the Java language. The meaning of the keyword will be explained later.
Working with Primitive Data Types
Java, such as programming languages like C and C + +, supports data type built-in, which is also called primitive data type. There are 8 types of data in the primitive Java:
Boolean *: This type of data used to represent binary conditions: true or false. So, on the level of Java, size 1 bit. bits