내 친구가이 코드 조각을 보냈지 만 작동하지만, "ss"의 의미를 이해할 수 없습니까? 누구든지 나를 도울 수 있습니까? 감사.Java for 루프 구문?
public static void main(String[] args)
{
String sentence;
int index=1;
String[] words;
System.out.print("Please enter a sentence: ");
sentence = EasyIn.getString();
words = sentence.split(" ");
for(String ss : words)
{
System.out.println("Word "+index+ " is "+ ss);
if(ss.matches("[a-zA-Z]+"))
{
System.out.println("Word "+ss+" is a good word");
System.out.print("\n");
}
else
{
System.out.println("Word "+ss+" is a bad word");
System.out.print("\n");
}
index++;
}
}
'ss'는'String' 변수 에서처럼? –
'for-each' 루프를 검색하십시오. –
[Java 자습서 :'for 문] (http://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html) – Jesper