集册 Java实例教程 遍历字符串的字符

遍历字符串的字符

欢马劈雪     最近更新时间:2020-01-02 10:19:05

465
使用String方法可在字符级别访问String。

String str = "Break down into chars"; 

System.out.println(str); 

for (char chr:str.toCharArray()){ 
/** from 
N o w J a v a . c o m**/

    System.out.println(chr); 

}