自动拆装箱,string和基本数据类型的相互转换

 1 package com.pang.demo1;
 2 
 3 public class Demo01 {
 4     public static void main(String[] args) {
 5         int i = 1;
 6         //转为包装类,自动装箱
 7         Integer a = i;
 8         //转为基本类,自动拆箱
 9         int value = a.intValue();
10         //基本数据类型,转化为string
11         String s = i+"";
12         //string转化为基本数据类型
13         int int1 = Integer.parseInt(s);
14         
15     }
16 }

 

posted @ 2017-06-16 21:32  更好遇见你  阅读(183)  评论(0编辑  收藏  举报