ArrayList에 입력 한 내용을 인쇄하려고하는데 합법적 인 이름을 명확하게 입력하면이 [[email protected], [email protected], [email protected]]
과 같은 이상한 결과가 계속 발생합니다. 그래서 내 코드를 살펴보고 문제가 될 일을 참조하십시오입력 된 ArrayList를 출력하는 방법
public class player {
private static String name;
public void setName(String pName)
{
name = pName;
}
public String getName()
{
return name;
}
}
내가 너희들을 마련 알려주십시오 :
if (o == 5) {
double RD, t, old, x;
String tournament, player;
int a, number_of_players, place;
ArrayList<player> players = new ArrayList<player>();
System.out.println("1:Add a tournament \t2:View Existing");
a = keyIn.nextInt();
if (a == 1) {
System.out.println("\nEnter tournament name");
tournament = keyIn.next();
System.out.println("\nEnter number of players");
number_of_players = keyIn.nextInt();
System.out.println("Enter players");
for (int i = 0; i < number_of_players; i++) {
String name = keyIn.next();
player plr = new player();
plr.setName(name);
players.add(plr);
}
System.out.println("Enter places for");
System.out.println(players);
place = keyIn.nextInt();
가 여기 내 player
클래스입니다! 감사!
해당 줄의 세미콜론을 제거하십시오.'if (a == 1); {'. – Tom