读取字符串 封装到数组里面
作者:互联网
public static void main(String[] args) {
String str="a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
String[] strArray=null;
strArray = convertStrToArray(str);
String s = printArray(strArray);
for (String s1 : strArray) {
System.out.println(s1);
}
}
//使用String的split 方法
public static String[] convertStrToArray(String str){
String[] strArray = null;
strArray = str.split(","); //拆分字符为"," ,然后把结果交给数组strArray
return strArray;
}
标签:封装,读取,strArray,convertStrToArray,static,str,字符串,null,String 来源: https://blog.csdn.net/qq_39505065/article/details/97402092