JAVA variable type, definition variable, java variable Type Definition

Source: Internet
Author: User

JAVA variable type, definition variable, java variable Type Definition

Common Data Types in JAVA

Data Type Data Type description Description
Char Character Type Used to store a single character, such as gender "male", "female", electric lights "on", and "off"
Int Integer Used to store integers, such as 24 hours a day and 31 days a month.
Double Double Precision Used to store decimals. For example, the price of Mengniu's breakfast milk is 1.3 yuan, and the phone's standby time is 6.5 hours.
String String It is used to store a string of characters, such as "My hobby is playing football" and "I like Java programs"
Boolean Boolean Type Only one of the two values can be assigned: true or false)

 

 

 

 

 

 

Define Variables

Public class Test {public static void main (String [] args) {char a = 'P'; // declare and assign a value to the int number = 123 variable of the character type (single character; // declare and assign the integer Variable double B = 1.5; // declare and assign the double-precision variable String d = "zifuchuan "; // declare and assign values to string variables // output System. out. println (a); System. out. println (number); System. out. println (B); System. out. println (d );}}

 

Related Article

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.