Create
a longer learning java programming language we must first know the basics.
Without the strong foundations that we will have trouble when we create more
complex applications. The following outlines the basic fundamentals of the Java
programming language as well as the type-species variable. hope useful.
Variables
are used to store the specified value in the application program (computer
memory), this value is stored according to its type into a variable of the type
of value.
In the Java programming language, the types of variables used are:
In the Java programming language, the types of variables used are:
- Int : to store the value in an integer number, for example: 5
- Double : to store the value in a decimal number, for example: 08
- String : text to save the value of words, for example: "learning java"
- Boolean : to save the value of true or false, for example: true
To declare a variable that can store these values are used the following syntax :
Code:
[tipe_variabel] [nama_variabel];
Contoh dalam program :
Code :
public class Contoh {
public static void main(String[] args) {
int a = 5;
double b = 08;
String c = “one day yupi….yupi….”;
boolean d = false;
// mengeluarkan nilai diatas ke layar
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
// ganti nilai variabel a
a = 500;
System.out.println(a);
}
}

No comments:
Post a Comment