我得到下面的錯誤:如何在同一行上打印來自多個ArrayLists的元素?
C:\Area52\AndroidProgramming>javac -d . ex1.java ex1.java:27: error:
no suitable method found for println(Object,Object)
System.out.println(players.get(0), batAvg.get(0)); ^ method PrintStream.println(Object) is not applicable (actual and formal argument lists differ in length)
這裏是我的代碼:
package one.exercise;
import java.util.*;
public class ex1
{
public static void main(String[] args)
{
ArrayList players = new ArrayList();
players.add("Joey");
players.add("Thomas");
players.add("Joan");
players.add("Sarah");
players.add("Freddie");
players.add("Aaron");
ArrayList batAvg = new ArrayList();
batAvg.add(.333);
batAvg.add(.221);
batAvg.add(.401);
batAvg.add(.297);
batAvg.add(.116);
batAvg.add(.250);
System.out.println(players.get(0), batAvg.get(0));
System.out.println(players.get(1)); //+ batAvg.get(1));
System.out.println(players.get(2)); //+ batAvg.get(2));
System.out.println(players.get(3)); //+ batAvg.get(3));
System.out.println(players.get(4)); //+ batAvg.get(4));
System.out.println(players.get(5)); //+ batAvg.get(5));
}
}