Today is the first weekend to learn Java, I was wondering if I have made the wrong choice, but later thought. Now that you have chosen this road, you must not be afraid of all the thorns and bumps on the road; say it negatively, even if it is dead, and die on this road.
What does Java say? Java is a simple, object-oriented, distributed, interpreted, secure, portable, high-performance multithreaded language. For this concept, I still feel more abstract, empty. In the first week of learning Java, we had an initial understanding of Java's underlying syntax, including: Java data types, variables, constants, expressions, statements, and so on. Also learned about the origins of Java, development and other common sense, example: the father of the Java language-----James Gosling. May 23, 1995, Java technology was formally born. Java draws on many of the language features of C and C + +, so there are many similarities between Java's underlying grammar structure and C language.
Java technology is divided into three platforms: Java SE, Java ME, Java EE.
Editing of Java source program:
Public class hello{
Public static void Main (string[] args) {
System.out.println ("Hi Java");
}
}
The written Java source files are compiled into Java bytecode (. class files) By the Java compiler, which is then loaded by the JVM (Java Virtual machine) for class loading. Basic elements of Java: Character sets, identifiers, keywords, variables, constants, statements, and other programming languages. In Java, there are many keywords (example: class,break,void,public,static, etc.) and identifiers (note: Naming rules: 1 cannot be keyword 2 cannot start with a number 3 identifiers have letter case differences, no maximum length specified), There are also eight data types: integer (int,byte,short,long) float (float,double), char (char), and Boolean (Boolean). < note: Boolean only true and false two values >. A variable in Java is either one of eight basic types, or a reference type (String), a keyword final in Java for declaring constants, and three declarations in Java://,/*...*/,/**...*/(/**...*/is a document comment).
The integer number polygon is treated as an int type by the JVM. If the literal is a long type, you must add L to the end of it, and floating-point literals are treated as double by the JVM. If the literal is a float type, it must be appended with F at the end.
There are control processes in Java, however, in programming, we often need to change the program control process, that is, the execution order of statements, there are three basic techniques can change the flow of control process: 1 Call Method 2 Select (If/else,switch) 3 loop (for,while,do/ While).
The syntax form of the IF/ELSE statement:
if (Boolean expression) {
Executes when the Boolean expression is True
}else{
Executes when the Boolean expression is False
}
The syntax form of the switch statement:
Switch (variable) {
Case Value:
Statement
Break
Case:
Statement
Break
...
...
...
Default
Statement
}
The syntax form of the while:
while (Boolean expression) {
Statement
}
The grammatical form of do/while:
do{
Statement
}while(boolean expression)
For syntax form:
for (initial value; Boolean expression; update) {
Statement
}
Java first week