title: How to pass mutable objects by value to java
body: <p>Is there any way that I can pass mutable Objects by value to a function in java?</p>
  
  <p>What I actually want is to pass an object to a method, do some operations on it (change it) and again call that method with that old object only(not the changed value). </p>
  
  <p>here is some sample:</p>
  
  <pre><code>    { MyObj obj = new MyObj(); obj.setName("name");
  
      append(obj); 
      System.out.println(obj.name);
  
      prepend(obj); 
      System.out.println(obj.name);
  
      }
  
      void append(MyObj obj){ obj.name+="1"; }
  
      void prepend(MyObj obj){ String a = "1"; obj.name=a+obj.name; }
  </code></pre>
  
  <p>At the end of this code, I want output as:</p>
  
  <pre><code>name1
  1name
  </code></pre>