我試圖發送到來自用戶輸入的字符串的ArrayList:JAVA - 添加到ArrayList的一個字符串
private static void adicionarReserva() {
Scanner adiciona = new Scanner(System.in);
System.out.println("Numero da pista: ");
int nPista = adiciona.nextInt();
System.out.println("Numero de jogadores: ");
int nJogadores = adiciona.nextInt();
System.out.println("Data Inicio: ");
String data_inicio = adiciona.next();
Reservas reserva = new Reservas(nPista, data_inicio);
ArrayList<Jogadores> nome_jogador = new ArrayList();
for (int i=1;i<=nJogadores;i++) {
System.out.println("Nome Jogador: ");
String nome = adiciona.next();
nome_jogador.add(nome);
}
reserva.addJogadores(nome_jogador);
}
在我的課叫做:RESERVAS,我有這個:
public void addJogadores(Jogadores lista_jogadores) {
this.lista_jogadores.add(lista_jogadores);
}
但我有此錯誤:
nome_jogador.add(nome);
The method add(Jogadores) in the type ArrayList is not applicable for the arguments (String)
而這一次:
reserva.addJogadores(nome_jogador);
The method addJogadores(Jogadores) in the type Reservas is not applicable for the arguments (ArrayList)
任何一個可以幫助我嗎?