Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
Cómo almacenar matrices de cadenas dentro de una iteración for & for-each

Aquí están for loop y for (Element link : links) . Quiero almacenar todos los title de los elementos en la line[]

Qué tengo que hacer ?

 String[] line = new String[100]; for (int i = 0; i < numberOfResultpages; i++) { ...... for (Element link : links) { String title = link.text(); String url = link.absUrl("href"); url = URLDecoder.decode(url.substring(url.indexOf('=') + 1, url.indexOf('&')), "UTF-8"); if (!url.startsWith("http")) { continue; // } System.out.println("Title: " + title); line[ numberOfResultpages ]=title; //I don't know how to store every title element into line here // } } }

Actualizar

numberOfResultpages no es el tamaño máximo de la matriz un numberOfResultpages puede tener muchos title de elementos

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

String[] line = new String[numberOfResultpages * links.size()]; // assign adequate size to line array. int idx = 0; for (int i = 0; i < numberOfResultpages; i++) { ... for (Element link : links) { ... line[idx++]=title;
over 4 years ago · Santiago Trujillo Report

0

Prueba usando ArrayList :

 List<Strng> list=new ArrayLst<String>(); for (int i = 0; i < numberOfResultpages; i++) { ......... //Every thing same //add like this, ArrayList is Dynamic in Size list.add(title); } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!