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

289
Views
Java: la matriz no recibe valores

Aquí está el código. lista es una variable global.

 ArrayList<LatLng> list = new ArrayList<LatLng>(); public void addCoordinate(double a, double b){ list.add(new LatLng(a,b)); } public ArrayList<LatLng> readItems(int ignore) throws JSONException { addCoordinate(2.0,2.0); JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, showUrl, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { System.out.println(response.toString()); try { JSONArray records = response.getJSONArray("locations"); for (int i = 0; i < records.length(); i++) { JSONObject locations = records.getJSONObject(i); double latitude = locations.getDouble("Latitude"); double longitude = locations.getDouble("Longitude"); // double lat = Double.parseDouble(latitude); // double lng = Double.parseDouble(longitude); list.add(new LatLng(latitude,longitude)); } addCoordinate(3.0,3.0); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { System.out.append(error.getMessage()); } }); //requestQueue.add(jsonObjectRequest); addCoordinate(1.0,1.0); return list; }

Solo devuelve los dos valores cuando se llama a getCoordinate (el 1,1 y el 2,2), pero se salta el (3,3). Si alguien tiene una solucion se lo agradeceria gracias.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

(3,3) se agregará solo después de llamar a onResponse.

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!