Types of Java variables, defining variables

Source: Internet
Author: User

Common data types in Java

Data type Data type Interpretation Description
Char Character type Used to store a single character, such as: Gender "male", "female", Electric Light "on", "off"
Int Plastic Used to store integers, such as the time of day is 24 hours, January is 31 days
Double Double precision For storing small trees, such as Mengniu breakfast milk price is 1.3 yuan, mobile phone standby time is 6.5 hours
String String Used to store a string of characters, such as "My hobby is playing football", "I Like Java program"

Defining variables

 Public classtest{ Public Static voidMain (string[] args) {CharA = ' P ';//A variable that declares and assigns a character shape (a single character)        intNumber = 123;//variables that declare and assign values to reshape        Doubleb = 1.5;//variables that declare and assign double-precision shapesString d = "Zifuchuan";//a variable that declares and assigns a string type//OutputSystem.out.println (a);        SYSTEM.OUT.PRINTLN (number);        System.out.println (b);    System.out.println (d); }}

Types of Java variables, defining variables

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.