title: Pass an ArrayList<Object> as an argument to a method, process the arrayList and return it - Java
body: <p><strong>EDIT:</strong></p>
  
  <p>Sorry forr the misspellings and typos, I didn't want to put my code here so I tried to make a new look a like code to express my question.</p>
  
  <p>Here is the actual code I'm using, I just removed some parts of it as they are not related to my question, I think, otherwise just ask me and I'll put it here as well.</p>
  
  <p>Heres the actual code:</p>
  
  <pre><code>public class Dados {
  
      private String sta;
      private String ap;
      private int startTime;
      private int endTime;
      private int repetitionSTA;
      private int pingPong;
      private int tt_previous;
      private int tt_next;
      private int id;
  
      public Dados(int id, int startTime, int endTime, String ap, String sta, int repetitionSTA, int ttprevious, int ttnext, int ppong)
      {
          this.sta = sta;
          this.ap = ap;
          this.startTime = startTime;
          this.endTime=endTime;
          this.pingPong = ppong;
          this.tt_next = ttnext;
          this.tt_previous = ttprevious;
          this.id = id;
          this.repetitionSTA = repetitionSTA;
      }
  
      // SET
  
      public void setPingPong()
      {
          this.pingPong = 1;
      }
  
  
      //GET
  
      public int getPingPong()
      {
          return this.pingPong;
      }
  
  }
  </code></pre>
  
  <p>//another class from now on</p>
  
  <pre><code>public class Queries extends LigarBD{
  
      String dbtime = null; 
  
      int id = 1;
  
      TreeMap&lt;Integer, ArrayList&gt; tmValores = new TreeMap&lt;&gt;();
      ArrayList&lt;Dados&gt; listaObjectos = new ArrayList&lt;&gt;();
      ArrayList&lt;Dados&gt; listaObjectos2 = new ArrayList&lt;&gt;();
  
  
      public ArrayList getUniqueStations(String server)
      {
          ArrayList&lt;String&gt; listaSTA = new ArrayList&lt;&gt;();
  
          String query = "SELECT distinct calling_station_id FROM java_logs;";
  
          try
          {
              super.ligar(server);
              Statement s = super.getConexao().createStatement();
              ResultSet rs = s.executeQuery(query);
              while (rs.next())
              {
                  listaSTA.add(rs.getString(1));
              }
              rs.close();
              s.close();
              super.desligar(super.getConexao());
  
          }
          catch (Exception e)
          {
              JOptionPane.showMessageDialog(null, "Error at listing all unique stations. Reason -&gt; "+e.getMessage());
              System.out.println("Error at listing all unique stations. Reason -&gt;  "+e.toString());
          }
  
          return listaSTA;
      }
  
  
      public ArrayList getStationData(String mac, String server)
      {
  
          try 
          {
              super.ligar(server);
              Statement s = getConexao().createStatement();
  
              ResultSet rs = s.executeQuery("SELECT timestamp-acct_session_time, timestamp, called_station_id, calling_station_id "
                                          + "FROM java_logs where calling_station_id = '"+mac+"';"); // retirar STA da query *******************
              //System.out.println("Executing the Query on+"+server+" - UniqueSTA - Query number: 1?");
              int repetitionSTA=1;
              while (rs.next()) 
              {              
                  Dados d = new Dados(id, rs.getInt(1), rs.getInt(2), rs.getString(3), rs.getString(4), repetitionSTA, 0, 0, 0);
  
                  listaObjectos2.add(d);
                  repetitionSTA++;
                  id++;
              }
  
              rs.close();
              s.close();
              super.desligar(super.getConexao());
          }
          catch (Exception e) 
          {
              JOptionPane.showMessageDialog(null,"Error at Select Query. Reason -&gt; "+e.getMessage());
          }
  
          return listaObjectos2;
      }
  
  }
  </code></pre>
  
  <p>Another class:</p>
  
  <pre><code>public class Pingpong {
  
      ArrayList&lt;Dados&gt; dadosArray = new ArrayList&lt;&gt;();
  
  
  
      Queries q = new Queries();
  
      TreeMap&lt;Integer, ArrayList&gt; mapa = new TreeMap&lt;&gt;();
      ArrayList&lt;Dados&gt; arrayDeDados = new ArrayList&lt;&gt;();
  
  
      public ArrayList detectPingPongArray(int threshold_access_session_time, int threshold_transition_time, ArrayList&lt;Dados&gt; dadosSTA)
      {
          dadosArray=dadosSTA;
          for(int i = 1; i&lt;arrayDeDados.size()-1; i++)
          {
              dadosArray.get(i).setPingPong();
          }
          return dadosArray;
      }
  
  
  }
  </code></pre>
  
  <p>And here is where I'm printing each object one by one:</p>
  
  <pre><code>ArrayList&lt;Dados&gt; dadosSTA = new ArrayList&lt;&gt;();
          ArrayList&lt;Dados&gt; dataForPPong = new ArrayList();
  
          ArrayList uniqueSTA = q.getUniqueStations("localserver");
  
          for(int i = 0; i&lt;uniqueSTA.size(); i++)
          {
              dadosSTA = q.getStationData(uniqueSTA.get(i).toString(), "localserver");
              dataForPPong = p.detectPingPongArray(5, 3, dadosSTA);
  
          }
  
          for(int i=0; i&lt;dataForPPong.size(); i++)
          {
              System.out.println("ID: "+dataForPPong.get(i).getId()+" STA: "+dataForPPong.get(i).getStation()
                      + " PingPong: "+dataForPPong.get(i).getPingPong());
          }
  </code></pre>
  
  <p>So I was expecting it to change the value of pingPong in all objects to 1 but it doesn't.</p>
  
  <p>I think the problem is with the returning from the method detectPingPongArray but I don't know where is the mistake.</p>
  
  <p>Anyone can pinpoint the problem here?</p>