包装类的简单使用

来源:互联网 发布:usb网络转换器买多少兆 编辑:程序博客网 时间:2024/05/22 05:28
package cn;import java.util.ArrayList;import java.util.List;public class Test1 {public static void main(String[] args) {// Integer i=new Integer(3);// //将包装类中封装的基本数据类型取出来// int x=i.intValue();// System.out.println(x);// List list =new ArrayList();// //自动装箱 ,将基本类型自动转化为包装类再加入集合// list.add(1);// System.out.println(list.get(0) instanceof Integer);Integer i = new Integer(3);// 自动拆箱。将包装类中封装的数据取出来,再和整型运算System.out.println(i + 9);}}

原创粉丝点击