Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
Java ArrayList<String[]>

I would like to create a 2D array named employees where I know the number of columns (fixed 5 and represent employee's data) but number of rows is somewhat dynamic. So I did something like this:

static ArrayList<String[]> employees = new ArrayList<String[]>();

I figured how to add employees but I can't figure out how to get a specific data out of one employee only, using .get() for example.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

get would return a row, which is a String[]. If you want a specific value from it, you'll have to subscript it using the [] operator:

String specificData = employees.get(1)[2]; // Or any other indexes
over 4 years ago · Santiago Trujillo Relatório

0

the first dimension which is any ArrayList you have to call by get() method to access and then the returned value is an array which you cann access by index:

ArrayList<String[]> employees = new ArrayList<String[]>();
employees.add(new String[] {"a", "b"});
System.out.println(employees.get(0)[0]);
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda