Simply put, we can think of variables as a box that can store items such as keys, cell phones, and drinks in this box, or we can replace them with new items that we want to store when we need them.
650) this.width=650; "src=" http://img.mukewang.com/535a6c980001e7ae04880153.jpg "/>
In Java, we describe variables by three elements: variable type, variable name , and variable value .
If we compare a variable to a hotel room, the data to be stored is like the guest who wants to stay, we can arrange it according to Guest's request to stay "standard room" or "Presidential Suite", and can quickly find the guest's information according to the room name. In the same vein, in a Java program, we can also save it in a variable space of the specified type according to the format of the data we need to save, and quickly locate it with the variable name!
650) this.width=650; "src=" http://img.mukewang.com/535a6c6000015cda02910139.jpg "/>
For example, we define a variable love, which is used to hold a string "Imooc", and in the program we can find the "IMOOC" stored in it just by finding the variable of love! Of course, we can also change the value of love into a new string "I love Imooc"!
650) this.width=650; "src=" http://img.mukewang.com/5358cb3400019b5606390263.jpg "/>
Operation Result: 650) this.width=650; "src=" http://img.mukewang.com/535a39c700017ac603250045.jpg "/>
Code:
public class helloworld{
public static void Main (string[] args) {
String hobby= "Hello World";
SYSTEM.OUT.PRINTLN (hobby);
}
}
Declares a variable hobby and assigns a value of Hello world! The print result is Hello world!
This article is from "Ghost" blog, please make sure to keep this source http://caizi.blog.51cto.com/5234706/1547639
Java Foundation---variables (iii)