-6

我的代码是这样的

     public class project 
      {
 public static void main(String[]args)
     {
   String[]players = TheTeamPlayers();
    printStringArray(players);
       }
    public static String[] TheTeamPlayers()
      {
String[]players={"Mark Thompson","John Carey","Pat Buckley","MichaelO'Connor","Finbarr Noonan","Kevin Drogan","Ray Kelly","Jonathan Shannon","Ronan Linehan"};
return players;
}
public static void printStringArray(String[]strings)
{
for(String s : strings)
{
System.out.println(" The Team Players Names Are: " + s );
}
}
    }
4

1 回答 1

0

你可以这样迭代:

 public static void  printStringArray(String[] players) { 
   for (int i =0; i < players.length;  i++)
    { 
       System.out.println(" The Team Players Names Are: " + players [i]); 
     } 
   } 

您还应该将变量命名为自描述的以避免混淆。

于 2015-03-08T00:39:30.300 回答