java String转int int转化为String

 

String转int

String str = "123";
int a = Integer.parseInt(str); System.out.println(a);
Integer b
= Integer.valueOf(str); System.out.println(b);
int c = Integer.valueOf(str).intValue(); System.out.println(c);

 

int转化为String

int i = 123;
String s
= String.valueOf(i); System.out.println(s);
String s2
= i + ""; System.out.println(s2);
String s3
= Integer.toString(i); System.out.println(s3);

 

posted @ 2018-10-17 13:34  草木物语  阅读(526)  评论(0编辑  收藏  举报