String遍历
public static void main(String[] args) {
String str2 = "字符串遍历";
stringTravelse(str2);
}
private static void stringTravelse(String str) {
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
System.out.print(c + " ");
}
System.out.println();
}
结果: 字 符 串 遍 历