验证中...
Languages: Java
Categories: 其他
Latest update 2019-12-03 11:57
gistfile1.txt
Raw Copy
package com.cast.it;
/**
* @author Administrator
* 包装类
* Integer
* Character 没有 ValueOf(String s) 和 parseXxx(String s)方法
* 其他包装类首字母大写
*/
public class Ceshi {
public static void main(String[] args) {
int se = 2;
//int转String
String se1 = se + "";
System.out.println(se1.getClass().getName());//返回对象类型
//String 转 int
//方法一
Integer se3 = new Integer(se1);//string -> integer
System.out.println(se3.getClass().getName());
int se4 = se3.intValue();//integer -> int
//方法2
int se5 = Integer.parseInt(se1);
System.out.println(se5);
try {
//Integer
int i = 20;
//int转 integer
Integer he = new Integer(i);
System.out.println(he.toString());
int s = he.intValue();//integer 转 int
System.out.println(he.getClass().getName());
System.out.println(s);
//Character
char sdf = 'b' ;
Character srg = new Character(sdf);
System.out.println(srg.toString());
} catch (RuntimeException e) {
e.printStackTrace();
}
}
}

Comment list( 0 )

Sign in for post a comment

Help Search