Java data type (basic data type) learning

Source: Internet
Author: User

Java data type (basic data type) learning

As with other languages, Java programming also exists, such as int a,float B. I have to understand the Java data type before I can learn the variables.

The data types of Java include basic data types and reference data types. Specific as follows:

The value ranges for each data type are as follows:

type name

keyword

occupied bytes

value range

byte-type

byte

1

-2^7~2^7-1

Span style= "font-size:10pt" > short integer

short

2

-2^15~2^15-1

integer

int

4

-2^31~-2^31-1

Span style= "font-size:10pt" > long int

long

8

-2^63~-2^63-1

single precision floating-point type

float

4

-3.4e38~3.4e38

Span style= "font-size:10pt" > double precision floating-point type

double

8

-1.7e308~1.7e308

character type

char

2

0~65535

Boolean type

Boolean

1

True or False

The range of values for each type can also be tested like this:

  1. Public class javatest2{
  2. Public Static void Main (string[] args) {
  3. System.out.println (byte.max_value+ "" +byte.min_value);
  4. System.out.println (short.max_value+ "" +short.min_value);
  5. System.out.println (integer.max_value+ "" +integer.min_value);
  6. System.out.println (long.max_value+ "" +long.min_value);
  7. System.out.println (float.max_value+ "" +float.min_value);
  8. System.out.println (double.max_value+ "" +double.min_value);
  9. }
  10. }

Java data type (basic data type) learning

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.