package com.hncu.myinteger;
public class MyIntegerDemo4 {
public static void main(String[] args) {
String s1 = "100";
int i = 200;
System.out.println(s1 + i);
//将字符串变为整型,Integer.parseInt(字符串对象)
System.out.println(i + Integer.parseInt(s1));
//int--->String)(整型变为字符串)
int i1 = 100;
String s = i1 + "";//字符串和任意类型连接都为字符串
//方法一:
// System.out.println(s+100);
//方法二:
String s2 = String.valueOf(i1+100);//使用字符串中的静态方法
// System.out.println(s2+100);
}
}
12-25
06-29
1351
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交