title: Can we assign values to objects passed in arguments without using return in Java?
body: <p>This might be the silliest question anybody ever asked, but just for curiosity, Can we assign values to Objects which are passed as arguments. For example</p>
  
  <pre><code>public class ForDemo3 {
      int i = 0;
      ArrayList cp = new ArrayList();
  
      public ForDemo3() {
          int j = 30;
          cp.add(j);
          cp.add(i);
          i = 5;
          j = 12;
          System.out.println("i = " + i + " &amp; j= " + j);
          assignDvalues(i, j);
          System.out
                  .println("After Restoring the values i = " + i + " &amp; j= " + j);
      }
  
      public void assignDvalues(Object... obj) {
          for (int n = 0; n &lt;= obj.length - 1; n++) {
              obj[n] = cp.get(n);
              System.out.println("" + obj[n]);
          }
      }
  
      public static void main(String[] args) {
          new ForDemo3();
      }
  }
  </code></pre>
  
  <p>I'm trying to develop checkpoint based recovery in java. And <code>cp</code> is a checkpoint object where values can be stored.</p>
  
  <p>Output of Above is </p>
  
  <pre><code>  i = 5 &amp; j= 12
    30
    0
    After Restoring the values i = 5 &amp; j= 12 
  </code></pre>
  
  <p>Edit
  Apologies i am not a great user of stackoverflow. I'm working on a framework for parallel computing. And there will be a function <code>savecheckpoint(List l)</code> which will be used to store list or array list to DB as a checkpoint, and another function<code>public object restoreCheckPoint(int i)</code> will restore the list. So far i'm able to save the checkpoint and then restore it back. But how can i assign back the values of the Objects or variables without effecting user's code? As given in the above example i want to restore the values using <code>assignDvalues()</code>. Is there any way to make it possible? </p>