Web-android Engineer first form -2-6 data types in Java

Source: Internet
Author: User

Source: http://www.imooc.com/code/1230

In general, in order to facilitate the storage of goods, we will specify the type of items each box can store, like in the "Smelly socks box" We will not put "bread"! Similarly, the storage of variables also pay attention to "categorize"!

The Java language is a strongly typed language. The popular point is that the data stored in Java is typed and must be determined at compile time. There are two kinds of data types in Java:

In the Java domain , the basic data type variable is stored in the data itself , whereas the reference type variable holds the spatial address of the saved data. Frankly, the basic data type variables are stored directly in the drawer, and the reference data type variable is stored in the drawer key, key and drawer one by one corresponding.

The common basic data types are:

You may have noticed:

Note: The difference between the float type and the double type, as well as the char type and the String type, has a related summary in the wiki, the small partners can go to see Oh ~ ~

string is a common reference data type that is used to represent a string. In the development of programs, many operations are done using strings, such as user names, passwords, e-mail addresses, etc. in the system.

PS: Other small partners on reference types will be detailed in the later course.

Task

Try your luck!

Which type of variable is used to save the following data?

Name: Adoration class Gender: Male
Winning Numbers: 18 Price: 120.5
Are you sure you want to close the program: TRUE

In the editor, specify the types of variables in rows 3rd, 4, 5, 6, 7

1  Public classhelloworld{2      Public Static voidMain (string[] args) {3Name= "Adoration Class";4Sex= ' man ';5Num=18;6price=120.5;7isok=true;8 System.out.println (name);9 System.out.println (sex);Ten System.out.println (num); One System.out.println (price); A System.out.println (IsOK); -     } -}

1  Public classhelloworld{2      Public Static voidMain (string[] args) {3String name= "Adoration class";4         CharSex= ' man ';5         intNum=18;6         Doubleprice=120.5;7         Booleanisok=true;8 System.out.println (name);9 System.out.println (sex);Ten System.out.println (num); One System.out.println (price); A System.out.println (IsOK); -     } -}

Web-android Engineer first form -2-6 data types in Java

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.