Source: http://www.imooc.com/code/1242
Had to accept the variable little temper :
1. Variables in Java need to be declared and then used
2, when the variable is used, you can declare the variable to be initialized at the same time, you can also declare the value after
3. Only one value can be assigned at a time in a variable, but multiple times may be modified
4. The variables defined in the main method must be assigned before the output
About string: Represents the type of data stored in a variable as a string, which is described in detail in the next section, Little anticipation ~ ~
Task
Let's get the fault!
Can you find out the error in line 3 in the editor?
1 Public class helloworld{2 Public Static void Main (string[] args) {3 String City; 4 System.out.println ("My Hometown in:" + City); 5 }6 }
1 Public class helloworld{2 Public Static void Main (string[] args) {3 String city= "Fuzhou"; 4 System.out.println ("My Hometown in:" + City); 5 }6 }
Web-android Engineer first form the rules for using variables in Java -2-7