Javase is mainly used for desktop applications, console development.
1-1 Some of the most common Java words:
public.
Class
Static statically.
void no return type
Main
String strings
Args parameter
of system Systems
Out output device
Print printing
Write the first code:
1 Public class Hello java{2 Public Static void Main (string[] args) {3 System.out.print ("Hello java");// code 4 } 5 }
Input specification: 1. Each level of the program and the previous level of the program staggered, with the TAB key, empty out of 8 spaces;
2. The curly braces are aligned with this level of code.
Common errors: 1. The class name "Hello Java" must be consistent with the program file name (and the casing needs to be consistent);
2.main method as the entrance of the program, Void is necessary;
3. "String", "System" S must be in the same capitalization, or there will be a program error, Java is case-sensitive;
4. The code line semicolon must have;
5. Quotation marks cannot be omitted.
1-2 notes for Java programs:
1 public class hello java{ 2 public static void main (string[] args) { 3 System.out.print (" Hello Java "); // single-line comment 4 /* 5 multiline comment 6 multiline comment 7 */ 8 } 9 }
1. The single-line comment begins with "//" and ends at the end of the line;
2. Multi-line annotations such as the above procedure.
1-3 several common output controls for Java
\ t: outputs 8 spaces, which is equivalent to a tab stop.
\ n: Line break.
11 Public classtest{22 Public Static voidMain (string[] args) {33 System.out.print ("Hello java\n");44 System.out.print ("you \ t good java");55 }66 }77//Output Results88Hello Java99 Hello Java
Note: The output control must be unloaded inside the double quotation mark.
First knowledge of Java