1, the basic components
The basic unit is composed of Java classes, class body also includes properties and methods.
Each application must contain a main () method, comprising main () method is called class - main class
package Number
public class First{
static String s1 = "您好"
public static void main(String[] args){
String s2="Java";
System.out.println(s1);
System.out.println(s2);
}
}
File names must be the same name as the class that First.java case-sensitive, java case-sensitive.
Package declaration, a java program consists of a number of classes, so the package where it is kind of where the package keyword, the package called Number.
2, variable declaration
- Global variables: type attribute, declared in the class body. (Also known as member variables)
- Local variables: the method attributes declared in the method body.
3, the preparation of main () method
- public, static, void permission modifier are main () method, the static modifier, the return value modifier.
- main () method must be declared as public static void.
- String [] args an array of type string. Is the main () parameters.