Source: http://www.imooc.com/code/1183
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.
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!
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"!
Operation Result:
Task
Self-test time is up!
In the editor, enter the code for the 3rd line to define a variable hobby, save the "Mu net" this string
Operation Result:
Public class HelloWorld { publicstaticvoid main (string[] args) { = "mu class net" ; SYSTEM.OUT.PRINTLN (hobby); }}
Web-android Engineer first-2-4 variables