Java Foundation---variables (iii)

Source: Internet
Author: User

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)

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.