Web-android Engineer first form the rules for using variables in Java -2-7

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.