字符转数组,数组转字符串,去出字符串中特定位置的字符
程序员文章站
2022-05-29 13:52:47
...
package interview01;
import java.util.Arrays;
public class interview001 {
public static void main(String[] args) {
// 面试第一题,对字符串的操作
int a[]=new int [5];
System.out.println(a.length);//length 数组的长度
String name="yangbomingtian";
System.out.println("字符串长度为"+name.length());//字符串长度
char a1[];
char a3=name.charAt(4);
System.out.println(a3);
a1=name.toCharArray();//将字符串转换成字符数组
//a1=Arrays.Sort(a1);;
String name1=Arrays.toString(a1);//将字符数组转换成字符串
System.out.println(a1);
System.out.println(name);
for(int i=0;i<a1.length;i++) {
System.out.print(a1[i]+",");
}
System.out.println("name1 size"+name1.length());
System.out.println("字符串"+name1);
}
}