Java from entry to proficient Chapter 8 Packaging Class

Java from entry to proficient Chapter 8 Packaging Class

Java is an object-oriented language. Classes in Java connect methods and data to form their own processing units. But basic type objects cannot be defined in Java. In order to treat basic types as objects for processing and connect related methods, Java provides wrapper classes for each basic type. Such as the packaging class Integer for int type values ​​and the packaging class Boolean for boolean values, etc., so that these basic types can be converted into objects for processing.

One, Integer

The Integer, Long, and Short classes in the java.lang package encapsulate the basic types int, long, and short into one class, respectively. These are all subclasses of Number. The difference is that they encapsulate different data types, and the methods they contain are basically the same.

The Integer class wraps a value of the basic type int in the object. The object of this class contains a field of type int. This class provides multiple methods to convert between int type and String type. It also provides other constants and methods that are very useful when dealing with int types.

1) Construction method The
Interger class has the following two construction methods.

  • Interger(int number)

Guess you like

Origin blog.csdn.net/zhengzaifeidelushang/article/details/110956556