允許我問一個愚蠢的問題。我目前正在做我的教程工作,但我沒有得到(charcode:message)的意思。for(int charcode:message)
public static void main(String[] args) {
final int [] message =
{82, 96, 103, 103, 27, 95, 106, 105, 96, 28};
//the secret message
final int key = 5;
//key to unlock the message
for (int charcode: message){
System.out.print((char)(charcode + key));
}
//termincate with a newline
System.out.println();
}
它的簡寫'爲(INT i = 0;我
bdares
2011-05-30 06:46:19
請參閱[Java中的增強for循環表示法](http://stackoverflow.com/search?q=enhanced+for+loop)。它是句法糖。 – 2011-05-30 06:46:46