当前位置:网站首页>Packaging
Packaging
2022-04-21 18:13:00 【RhineHe_ hjs】
Packaging
The reason for the introduction of packaging
We all know java It's pure object-oriented programming , But it contains 8 Basic data type in , They are used to create objects , Therefore, the packaging class is introduced , Corresponding to eight basic data types , The following are the packaging classes corresponding to the eight basic types .
- byte -->Byte
- char -->Character
- short -->Short
- int -->Integer
- float -->Float
- double -->Double
- long -->Long
- boolean -->Boolean
Methods of packaging class
- Manual packing box : Corresponding packaging .valueof(data);
Integer integer = Integer.valueOf(100);
Character character =Character.valueOf('c');
- Manual unpacking :
int num =integer.intValue();
char ch = character.charvalue();
Here, I'll just list these two , Other types can be used as above , In addition to using the methods provided by the packaging class to pack and unpack ,java It also provides us with automatic packing and unpacking mechanism .
Automatic packing and unpacking
- Automatic packing box
Integer integer2 =12;
- Automatic dismantling
int num2 = integer;
Test the code written by yourself
public class PInteger {
public static void main(String[] args) {
// Manual packing box -->> Corresponding packaging .valueOf( Package data );
Integer integer = Integer.valueOf(100);
Character character =Character.valueOf('c');
System.out.println(" After packing box :"+integer);
System.out.println(" After packing box :"+character);
// Manual unpacking -->> Wrapper class object .valueof();
int num =integer.intValue();
char ch =character.charValue();
System.out.println(" After unpacking :"+num);
System.out.println(" After unpacking :"+ch);
// Automatic packing box
Integer integer2 =12;
Character character2 = 'a';
System.out.println(" After automatic packing :"+integer2);
System.out.println(" After automatic packing :"+character2);
// Automatic dismantling
int num2 = integer;
char ch2 =character;
System.out.println(" After automatic unpacking :"+num2);
System.out.println(" After automatic unpacking :"+ch2);
}
}
Tips
The above is just my own opinion , If the same is purely accidental . If there is a mistake , Please understand , Don't spray ! If there is gain or doubt , Comments are welcome on thumb up !
版权声明
本文为[RhineHe_ hjs]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211801130792.html
边栏推荐
- MySQL的默认用户名和密码的什么?
- A common CommonDialog
- 终于有人讲明白了!原来这才是全球低时延一张网技术
- Interface test framework practice (II) | interface request assertion
- Logstash ~ filter of logstash
- Live broadcast with goods source code, different writing methods of gradient status bar
- 你已经用 SharedPrefrence 的 apply() 替换 commit() 了吗?
- Look at how the technology house saves Xueba machine. I repaired my laptop with 10 yuan
- 【acwing】1118. 分成互质组 ***(DFS)
- C语言进阶第48式:函数设计原则
猜你喜欢

Interface

Have you replaced commit() with sharedprefrence's apply()?

MySQL - remote connection to non local MySQL database server, Error 1130: host 192.168.3.100 is not allowed to connect to this MySQL s

最基本的JDBC模板及数据库乱码处理

Laravel soar (2. X) - automatically monitor and output SQL optimization suggestions and assist laravel to apply SQL optimization

Debugging garbled code of vs2019 visual studio terminal

为拿几家大厂Offer,“闭关修炼

Eating this open source gadget makes MCU development as efficient as Arduino

Detailed explanation of kubernetes (IV) -- kubernetes deployment based on kubedm

靶机渗透练习80-Momentum:1
随机推荐
IoT平台如何实现业务配置中心
Mycat水平分表(全局表)
【论文精读】Stable Linear Structures and Seam Measurements for Parallax Image Stitching
2022超星学习通:媒体创意经济、走进东盟、职业生涯提升、音乐鉴赏、突发事件及自救
Akismet plugin tutorial WordPress prevent spam filtering plugin
Interface test framework practice (II) | interface request assertion
2022超星学习通《新伦理学》答案
信息系统项目管理师专有名词英文缩写&常见词汇
The MySQL database in MySQL is missing
How does IOT platform realize business configuration center
Eating this open source gadget makes MCU development as efficient as Arduino
为拿几家大厂Offer,“闭关修炼
JSON. Stringify() and JSON parse()
Summary of mongodb user permissions
靶机渗透练习79-Venom
Shallow comparison between oceanbase and tidb - implementation plan
mysql 中的mysql数据库不见了
一个通用的CommonDialog
mysql8. Cannot start after 0 setting ignores case
C# operator