1.java中String字符串中常用方法以及遍历字符串中每个字符的方法

字符串操作的方法有:


 遍历字符串中每个字符的操作方法

String s="algjgigjl";
#遍历方法1
char ch;
for(int i=0;i<s.length();i++){
    ch=s.charAt(i);
}
#遍历方法2  用char数组接收每个字符
char[] arr=s.toCharArray();
for(int i=0;i<arr.lengh;i++){
    ch=arr[i];
}
#遍历方法3 用byte数组接收每个字符
byte[] arr=s.getBytes();
for(int i=0;i<arr.length;i++){
    ch=arr[i];
}
原文地址:https://www.cnblogs.com/mitchyuu/p/12772132.html