字符串的遍历,获取字符串每一个字符

for循环实现:

String B = "ABCDEFG";

for (int x=0;x<5;x++){

System.out.println(B.charAt(x));      //ABCDEFG

}

 

length()实现:

for (int x=0;x<s.length(0;x++){

System.out.println(B.charAt(x));     //ABCDEFG

}