我用Java编写了这段代码,思考了一下使用
String [] whatever
和 String whatever[]
的区别。如果有人能告诉我发生了什么,最好使用 String [] whatever
= {} 还是使用 String whatever[]
= {},或者说它已经过时了。请注意,不要修改HTML标记。public class Snippet136
{
public static void main(String [] args)
{
String names[] = {"Jhonny", "Edurardo", "Francis", "Franklin", "Freedy"};
String [] eyes_colors = { "blue", "red", "black", "green", "black"};
System.out.print("Names:");
for (String name: names) {
System.out.print( " " + name );
}
System.out.print("\n\nEyes colors:");
for ( String eyes_color: eyes_colors ) {
System.out.print( " " + eyes_color );
}
}
}