Learn to record Java value types and reference types

Source: Internet
Author: User
Tags object object

8 Basic Types

One, 4 types of integral type
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
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

Second, Interface interface reference
Can be created by us, I don't speak much here, mainly to explain the interface in several Java libraries interface

List<e>: list, the user of this interface can precisely control the insertion position of each element in the list. The user can index an integer based on the element

(The position in the list) accesses the element and searches for the element in the list. The List interface provides two ways to search for a specified object. From

Performance standpoint, these methods should be used with care. In many implementations, they perform a high-overhead linear search. List Connection

Port provides two ways to efficiently insert and remove multiple elements from anywhere in the list.

Add (): Inserts the specified element in the list.

Remove (): Removes the element from the specified position in the list.

Get (int index): Returns the element at the specified position in the list.



Map<k,v>:

K-The type of key maintained by this mapping

V-the type of the map value maps the key to the value of the object. A map cannot contain duplicate keys, and each key can be mapped to at most one value.

Put (K key,v value): Associates the specified value with the specified key in this map (optional operation). If this mapping previously contained a key of the

Mapping relationship, the old value is replaced with the specified value (if and only if true is returned, the mapping m contains the mapping of the key K). Remove (Object key) If there is a mapping relationship for a key, it is removed from this mapping (optional operation). More specifically, if this mapping contains a mapping relationship from the key k to the value V that satisfies (Key==null k==null:key.equals (k)), the mapping relationship is removed. (The map can contain a maximum of one such mapping relationship.) Get (Object Key): Returns the value mapped by the specified key, or null if the mapping does not contain a mapping relationship for the key.

Here we mainly use the string List Map Object is the most commonly used number arraylist<e> arrays, etc.

Can examine the JDK API

These classes and interfaces are

Java.lang: Provides the basic class for programming using the Java programming language.

And

Java.unit: Contains the collection framework, legacy collection classes, event models, date and time facilities, internationalization, and various utility classes (string tag generator, random number generator, and bit array).

Learn to record Java value types and reference types

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.