如果您输入happy,它将显示
ħ
一
P
P
ý
现在我有这个:
public static void three(){
String x = keyb.next();
int y= x.length();
char [] word = new char [y];
System.out.println("It has " + y);
for (int i = 0; i < x.length(); i++) {
System.out.println(x);
}
}
只是让单词出现了多少个字符。但我只是想让每个角色都缩进。拜托,谢谢!
答案 0 :(得分:2)
这很简单:
String str = "happy";
for (int i = 0 ; i < str.length() ; i++){
System.out.println(str.charAt(i));
}