Friday, February 23, 2024
Home Lastest What is packaging and what are its categories?

What is packaging and what are its categories?

by admin
0 comment

What is packaging and what are its categories?

each basic type of Java corresponds to a wrapper type. For example, the wrapper type of int is integer and the wrapper type of double is double. There are four main differences between basic types and packaging types

1 The wrapper type can be null, but the basic type cannot be

it enables the wrapper type to be applied to POJO, but the basic type cannot
POJO: a simple and irregular Java object with only attribute fields and setter and getter methods, as shown in the following example

banner

class Writer {
private Integer age;
private String name;

public Integer getAge() {
return age;
}

public void setAge(Integer age) {
this.age = age;
}

public String getName() {
return name;
}

public void setName(String name) {
this. Name = name;
}
}
why does the attribute of POJO have to use packing type
Alibaba java development manual has detailed instructions
the query result of the database may be null. If the basic type is used, the exception will be thrown because it is necessary to unpack automatically (convert the packaging type to the basic type, for example, convert the integer object to the int value)

2. Wrapper types can be used for generic types, while basic types cannot

List = new ArrayList & gt; ();
//prompt syntax error, insert “” to complete
List = new ArrayList & gt; ();
3. Basic types are more efficient than wrapper types

basic types store specific values directly in the stack, while wrapper types store references in the heap

wrapper types take up more memory space than basic types. If there is no basic type, it is very cumbersome to pass a new packing type every time for frequently used data such as values
the values of two packaging types can be the same, but not equal
integer chenmo = new integer (10)
Integer wanger = new Integer(10);

System. out. println(chenmo == wanger); // false
System. out. println(chenmo.equals(wanger )); // When using to judge whether the two packages point to the same address. When the “= =” operator is applied to package type comparison, the result is likely to be inconsistent with the expected result

4. Automatic packing and automatic unpacking

with basic types and packaging types, they must be converted sometimes
the process of converting a basic type to a packing type is called boxing
on the contrary, the process of converting packaging type to basic type is called unpacking
before Java se5, developers need to unpack manually

integer chenmo = new integer (10)//Manual packing
int Wanger = chenmo intValue(); // Manual unpacking
in order to reduce the work of developers, Java se5 provides the function of automatic packing and unpacking

integer chenmo = 10//Auto packing
int Wanger = chenmo//Automatic unpacking

is equivalent to
= & gt

Integer chenmo = Integer. valueOf(10);
int wanger = chenmo. intValue();
in other words, automatic packing is through integer Valueof() completed; Automatic unpacking is through integer
note:

when automatic boxing is required, if the number is between – 128 and 127, the object in the cache will be used directly instead of re creating an object

packaging refers to the protective layer and decoration on the outside of objects. Different objects have different packaging methods and materials. Some containers such as boxes are also specially used for packaging

common packaging materials include bubble cloth, corrugated carton, envelope, inflatable packaging, etc., which can protect articles. Common decorative packaging materials include flower paper, red envelope bag, gift box, gift seal, etc

some items that need preservation (such as food) are often packaged in vacuum. In addition, plastic and aluminum foil are also common food packaging materials.

there are many kinds of packaging, with a wide range of materials, methods and uses
1. According to materials, it can be divided into paper packaging, plastic packaging, metal packaging, glass packaging, wooden packaging and packaging of other materials made of hemp, cloth, bamboo, rattan and grass
2. According to the function, it is divided into industrial packaging that performs the functions of transportation, storage and circulation and commercial packaging that plays the role of promotion or advertising for consumption
3. According to the packaging form, it is divided into two packages, inner package and outer package
4. According to the packaging method, it can be divided into waterproof and moisture-proof packaging, high shade separation packaging, antirust packaging and antistatic packaging. Water soluble packaging, UV proof packaging, vacuum packaging, insect proof packaging, buffer packaging, poly packaging, antibacterial packaging, anti-counterfeiting packaging, nitrogen filled packaging, deoxidization packaging, etc
5. According to the contents of the package, it is classified into food packaging, mechanical packaging, drug packaging, chemical packaging, electronic product packaging, military product packaging, etc
6. According to the degree of softness and hardness of packaging, it can be divided into hard packaging, semi hard packaging, soft packaging, etc.

You may also like

Leave a Comment

Soledad is the Best Newspaper and Magazine WordPress Theme with tons of options and demos ready to import. This theme is perfect for blogs and excellent for online stores, news, magazine or review sites.

Buy Soledad now!

Edtior's Picks

Latest Articles

u00a92022u00a0Soledad.u00a0All Right Reserved. Designed and Developed byu00a0Penci Design.