<pre name="code" class="java">import java.util.Arrays;
import java.util.List;
public class Test {
public static void main(String[] args) {
// String 转 int
int i = 100;
String s1 = "";
s1 = String.valueOf(i); // 第一种
s1 = i + ""; // 第二种
// int转String
String s2 = "100";
int j;
j = Integer.parseInt(s2); // 第一种
j = Integer.valueOf(s2).intValue(); // 第二种
// int 转 Integer
int a = 1;
Integer integer = new Integer(a);// 第一种
integer = Integer.valueOf(a);// 第二种
// Integer 转 int
a = integer.intValue();
//int[] 转 list
int b[] = {1,2,3,4,5,6};
List list = Arrays.asList(b);
}
}
Java中数据相互转换
最新推荐文章于 2024-04-26 16:58:27 发布