java字符串、数组、集合之间的转换
import java.util.Arrays;
import java.util.List;
import static java.util.Arrays.sort;
public class StringSplitDemo {
public static void main(String[] args) {
String str = "1,2,9,4,5,6,7,8,3";
System.out.println(str);
String[] split = str.split(",");
sort(split);
for (String e : split){
System.out.print(e);
System.out.print(" ");
}
System.out.println();
System.out.println("转换为带 [] 的字符串");
String toString = Arrays.toString(split);
System.out.println(toString);
List<String> list = Arrays.asList(split);
String[] strings = list.toArray(new String[0]);
for (String e : strings){
System.out.print(e);
System.out.print(" ");
}
String str010 = "000010";
System.out.println(str010);
int[] array = list.stream()
.mapToInt(Integer::parseInt)
.toArray();
for (int i : array){
System.out.print(i);
System.out.print(" ");
}
int n = Integer.parseInt(str010);
System.out.println(n);
}
}