Java primitive Type is the basic data type of java.There are 8 basic data types for Java: Byte (bytes), short (shorter integer), int (integer type), long (long), float (single-precision floating-point type), double (double-precision floating-point number Type), char (character type), Boolean (Boolean type )。All except the 8 are objects, including arrays.For example: Char is a basic data type (that is, the o
Java Tour (18)--Basic data type Object wrapper class, collection frame, data structure, collection,arraylist, iterator iterator,list use
Java defines all things as objects, and we want to use data types that can be referenced.
I. Object wrapper classes for basi
---restore content starts---1Java provides the corresponding wrapper class for 8 types. Because these 8 types are not classes or objects, they should not exist in Java (This is what is said here), it is emphasized that Java allows the value of the basic type directly to the corresponding
the X to the left of the equals sign.4) The integer object is stored in memoryInteger m = 127;Integer n = 127;System.out.println (M = = n);//result is trueInteger a = 128;Integer B = 128;System.out.println (A = = B);//result is FalseThe reason for this difference is that when the value is within the byte range (shaping less than or equal to 127), for the new attribute, if the value already exists, no new space is created, that is, M and N point to the same object.Summarize1. String and StringBu
Wrapper class (Wrapperclass), for packages of native data types. 1. Java provides 8 types of native data. However, in many places where the object type is required for use, and the native data type is not an object, the native data type needs to be wrapped as an object type for use. 2. Java provides
The Java language is an object-oriented language, but the basic data types in Java are not object-oriented, which in the actual use of a lot of inconvenience, in order to solve this shortcoming, in the design of the class for each basic data type to design a corresponding class to represent, The classes that correspond
In Java, there is a design principle of "all objects," the basic data types in Java completely do not conform to this design idea, because eight basic data types are not reference data types, so in order to solve such problems in Java, jdk1.5 introduced eight kinds of basic data types of wrapper classes.There are two m
an integer Intvalue method, the other wrapper class similar3. The type of packaging = = Judgment1. The valueof () method is called when the wrapper type is first created.For example, Integer i = 100; Equivalent to integer.valueof (i);★ To know that there is a Integercache static class in the Integer
data Type wrapper class I. OverviewJava provides a simple type of basic data for the data, as well as the corresponding wrapper class. With basic simple data types, you can improve the performance of your system and meet the needs of most applications. However, simple types do not have the attributes of an object and d
Java has eight basic data types, each of which has a corresponding wrapper class, such as an integer corresponding to int. Starting with jdk1.5, Java introduces automatic unboxing, which can be directly assigned as an integer i = 20, and the compiler automatically converts it to integer i = integer.valueof (20) for box
Java is an object-oriented language where classes in Java Connect methods to data and form self-contained processing units. However, you cannot define the base type (primitive type) in Java, and you can connect the related methods to treat the base type as an object. Java provides
The integer of the Java species is the wrapper type of int1. Integer is the wrapper type of int, the data type is class and the initial value is null2. When initializing int i = 1new Integer (1);3. Automatic packing and unpacking of class1) Automatic packingNew Integer (1); // using a normal declarative method Inte
,double,float,character,boolean Eight basic data wrapper class, look at the discovery is final decoration, After a closer look at the enum enum type, it is found that compiling with javac and then using JAVAP to Decompile is also a class that is compiled to final decoration, and that its enumeration values are all defined as member variables of the static final d
)void TrimToSize () attempts to reduce the storage space used for character sequences.5, StringBuilderAfter the jdk1.5, the object with the same function and StringBuffer appeared. It's StringBuilder.This is not covered in detail here. It would be nice to take a look at their differences.The difference is:The StringBuffer is thread-synchronized. Typically used for multithreading.StringBuilder is a thread that is not synchronized. Typically used for single threads. Its appearance improves efficie
Echarts Java wrapper class Library: Http://www.oschina.net/p/echarts-java Did not expect to like Echarts Java Encapsulation Class Library of people quite a lot, in the source code test example general purpose is to construct the s
values. * This method would always have the cache valuesin the range-128 to 127, * inclusive, and could cache other value s outside of this range. * * @paramI an {@codeint} value. * @returnAn {@codeInteger} instance representing {@codei}. *@since1.5*/ Public StaticInteger ValueOf (inti) {assertIntegercache.high >= 127; if(I >= integercache.low i Integercache.high)returnIntegercache.cache[i + (-Integercache.low)]; return NewInteger (i); }As can be seen here, for value int value betw
1. Java wrapper classWrapper class Correspondence Table
Basic data types
Packing class
Byte
Byte
Boolean
Boolean
Short
Short
Char
Character
Int
Integer
Long
Long
Float
First of all, why is there a packaging class? Java is an object-oriented programming language, and the basic type does not have the nature of the object, although Java can handle the basic type directly, but sometimes it needs to be treated as an object, which requires changing the base type to the wrapper type.The
http://www.verejava.com/?id=17159727064934public class Test {/** * @param args the command line arguments */public static void main (string[] args) { 8 basic data types corresponding to the wrapper class//byte byte//short short//int integer//long long/ /float float//Double double//char character//boolean boolean////boxing and disassembling Box//Boxing: Con
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.