Java basic type and reference type

Source: Internet
Author: User
8 Basic Types

Integer type 1 and 4
Byte 1 byte-128--127

Short 2 bytes-32,768 -- 32,767

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

Long 8 bytes-9,223,372,036,854,775,808 -- 9,223,372,036

Note: The number of bytes occupied by all data classes in Java is not related to the platform, and Java does not have any unsigned types.

2. Two floating point types
Float 4-byte 32-bit IEEE 754 single precision (6-7 digits valid)

Double 8-byte 64-bit IEEE 754 dual precision (15-bit valid digits)

3. Character units in Unicode encoding
Char 2-byte full Unicode Character Set

Iv. One truth type
Boolean 1-bit true or false Three reference types

Class

Interface

Array

I. Class class reference
It can be created by us. I will not talk about it here, but I will mainly explain the classes in several Java libraries.

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

Group. Object can be used to define all classes

For example:

Object object = new INTEGER (1); to define an interger class

Integer I = (integer) object; this object is forcibly converted into an interger class

String: string class represents a string, JavaProgramAll character strings (such as "ABC") in are implemented as such instances. Check sequence ticket

Characters, comparison string, search string, extract substring, create string copy, in this copy, all characters are converted into uppercase or lowercase.

Date: date indicates a specific moment, accurate to milliseconds. The date classes are generally replaced by calendar and gregoriancalendar.

Void: The Void class is a placeholder class that cannot be instantiated. It maintains a reference to the class object that represents the Java keyword void.

There are also corresponding classes such as integer long Boolean Byte Character double float short

Ii. Interface reference
It can be created by us. I will not talk about it here. I will mainly explain the interfaces in several Java libraries.

List <E>: list. You can precisely control the insert position of each element in the list. You can index an integer based on an element.

(Location in the list) access the element and search for the element in the list. The list interface provides two methods to search for a specified object. Slave

From the performance point of view, you should be careful to use these methods. In many implementations, they perform highly open linear search. List connection

The interface provides two methods to efficiently insert and remove multiple elements at any position in the list.

Add (): Insert a specified element to the list.

Remove (): removes the elements at the specified position in the list.

Get (INT index): return the elements at the specified position in the list.

Map <K, V>:

K-the type of the key maintained by this ing

The V- ing value type maps the key to the value object. A ing cannot contain duplicate keys. Each key can only be mapped to one value at most.

Put (K key, V value): Associate the specified value with the specified key in the ing (optional ). If the ing previously contains a key

The ing relationship replaces the old value with the specified value (only when true is returned can the ing relationship M contains the key K be said ). Remove (Object key) If there is a key ing relationship, remove it from this ing (optional ). To be more precise, if this ing contains? K = NULL: The ing between key K and value V of key. Equals (k) is removed. (This ing can only contain one such ing .) Get (Object key): returns the value mapped to the specified key. If the ing does not contain the ing relationship of the key, null is returned.

Here we mainly use string list map object as the most commonly used number arraylist <E> arrays, etc.

Check JDK APIs

These classes and interfaces are

Java. LANG: JavaProgramming LanguageBasic class for program design.

And

Java. Unit: Contains collection frameworks, legacy collection classes, event models, date and time facilities, internationalization, and various Utility Classes (string Mark Generator, random number generator, and Bit Array ).

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.