Data type in Java 2017-09-09

Source: Internet
Author: User
Tags object object

In Java, data types are divided into basic data types and reference types.

One: Basic type: Int (integer) short (Long Integer) float (floating point) double (double-precision floating point) char (character type) Byte Boolean

4 Integral types

BYTE 1 byte -128--127

Short 2 byte -32,768--32,767

int 4 byte -2,147,483,648--2,147,483,647 (more than 2 billion)

Long 8 byte -9,223,372,036,854,775,808--9,223,372,036854,775,807

Note: The number of bytes occupied by all data classes in Java is platform-independent, and Java does not have any unsigned types

Two, 2 types of floating-point
Float 4 byte 32-bit IEEE 754 single precision (significant bit 6–7 bit)

Double 8 bytes 64-bit IEEE 754 double precision (15 bits of significant digits)

Three, 1 types of Unicode encoded character units
Char 2 byte entire Unicode character set

Four, 1 kinds of truth types
Boolean 1 bit True or false
reference type: Except for variables of the underlying data type above, the rest are all reference data types;
3 Types of references

Classes Class

Interface Interface

Arrays Array

first, class reference
can be created by us, I don't speak much here, mainly to explain the classes in several Java libraries

Object:object is a very important class, object is the root class of the class hierarchy, each class uses object as the superclass, and all objects (including the number

groups) Implement this class of methods. Use object to define all classes

such as:

Object object= New Integer (1) to define a Interger class

integer i= (integer) object; In order to cast this object into the Interger class

The String:string class represents a string, and all string literals (such as "ABC") in a Java program are implemented as instances of this class. Check the order of the sequence

characters, compare strings, search strings, extract substrings, create a copy of a string, and in that copy all characters are converted to uppercase or lowercase.

Date:date represents a specific moment, accurate to milliseconds. The classes of date are generally now replaced by calendar and GregorianCalendar.

The Void:void class is a non-instantiated placeholder class that maintains a reference to a class object that represents the Java keyword Void.

also has a corresponding class such as: Integer Long Boolean Byte Character Double Float Short

Data type in Java 2017-09-09

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: 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.