public class IntegerTest{
public static void main(String[] args){
//String -> int
String s1 = "100";
int i1 = Integer.parseInt(s1);
System.out.println(i1 + 1); //101
//int -> String
String s2 = i1 + ""; //"101"字符串
System.out.println("s2 + 1); //"1011"
//自动装箱
Integer x = 1000;
//自动拆箱
int y = x;
//String -> Integer
Integer k = Integer.valueOf("123");
//Integer -> String
String e = String.valueOf(k);
}
}
String int Integer类型互换
最新推荐文章于 2024-07-14 22:18:32 发布