4.java variables

Source: Internet
Author: User

How to define the language of a variable in 1.java
Data type variable name;
2. How to assign a value language to a variable
Variable name = value;
3. What is the nature of the variable,
The essence is a piece of space in memory, this space has ' type ', ' name ', ' value '

int a;//a space in memory, the type of this space is int
a=100;
System.out.println (a);//access The block of memory by variable name
System.out.println (a);//Repeat Access

4
public class vartest{
public static void Mian (string[] args) {
int i=10;//Applies a space of type int, named I, and assigns a value of 10;
System.out.println (i);

Re-assign Value
i=100;
System.out.println (i);

Variables can be re-assigned, but cannot be declared repeatedly,
In the same domain, variable names cannot be duplicated;
write int i=200; it's wrong.

Variables in the Java language must be declared before they are assigned to use the
int A;
System.out.println (a);//It would be an error to write.


Note: Int i1,i2,i3=23;//declares three variables i1,i2,i3, type is int type, I1,I2 two variables are not assigned, only i3 variable is assigned, I1,I2, no assignment, i.e. not initialized so it cannot be accessed.

}
public static void Main ()
int i=200;
Not in the same domain China can be declared with the same variable name
}

4.java variables

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.