Introduction to Java data types and variables and constants

Source: Internet
Author: User

Java Introduction to data types and variables and constants

First, Java Data Type

    • The Java language is a strongly typed language that defines specific data types for each data and allocates different sizes of memory space in memory.

Note: integer default: int decimal default: Double

Defines the integer type long, which needs to be followed by a number L or L; For example: long num1 = 131313L;

To define float float, you need to add F or F after the number, such as: float num2 = 3.145F;

    • The size and range of memory occupied by eight basic data types

Second, variables

    • Definition of a variable

A storage area in memory

    • Characteristics of variables

The zone has its own name (variable name) and type (data type)

Data in this region can vary from one type to the same range

    • To define the format of a variable

Variable name of data type = initialization value;

Various definitions of variable writing methods:

Third, Constants

    • Definition of constants

Represents a value that cannot be changed, and the declaration is often final decorated

    • To define the format of a constant

Final data type constant name = initialization value

Such as: Final double pi=3.14;

Introduction to Java data types and variables and constants

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.