Java Basics---Data types in Java (v)

Source: Internet
Author: User

Data types in Java

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:

650) this.width=650; "src=" http://img.mukewang.com/535a6fc10001b8f604930247.jpg "/>

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.

Common basic data types are: 650) this.width=650; "src=" http://img.mukewang.com/535a745e000128fe07000130.jpg "/>

You may have noticed: 650) this.width=650; "src=" http://img.mukewang.com/536888bb0001b9f803900106.jpg "/>

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.


Code:

public class helloworld{
public static void Main (string[] args) {
String name= "Love Java";
Char sex= ' male ';
int num=18;
Double price=120.5;
Boolean isok=true;
SYSTEM.OUT.PRINTLN (name);
SYSTEM.OUT.PRINTLN (Sex);
SYSTEM.OUT.PRINTLN (num);
SYSTEM.OUT.PRINTLN (price);
System.out.println (IsOK);
}
}


Operation Result:

Love Java
Man
18
120.5
True


Description

Reference implementations:

1, the name is more than one character, you can use the String type

2, gender is a single character, you can use char type

3, the winning number is an integer, you can use the INT type

4, the price with a decimal, you can use double type

5, "Determine to close the program" is a value of Yes or no, representing a logical true or FALSE, so use the Boolean type


This article is from "Ghost" blog, please make sure to keep this source http://caizi.blog.51cto.com/5234706/1547641

Java Basics---Data types in Java (v)

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.