title: Trying to multiply an array Object by an int. Assigning new array, however original one gets changed
body: <pre><code>public class Money {
      private int moneyDollars;
      private int moneyCents;
      private int newDollars;
      private int newCents;
  
      public Money() {
          moneyDollars = 0;
          moneyCents = 0;
      }
      public Money(int dollars, int cents) {
          moneyDollars = dollars;
          moneyCents = cents;
      }
      public static Money[] multiply(Money[] moneys, int amt) {
          Money[] m = new Money[moneys.length];
          for(int i = 0; i &lt; moneys.length; i++) {
              m[i] = moneys[i];
          }
          for(int i = 0; i &lt; moneys.length; i++) {
              moneys[i].newDollars = moneys[i].getDollars() * amt;
              moneys[i].newCents = moneys[i].getCents() * amt;
              m[i].normalize();
              m[i].moneyDollars = moneys[i].newDollars;
              m[i].moneyCents = moneys[i].newCents;
          }
          return m;
      }
      @Override
      public String toString() {
          return getDollars() + "." + getCents();
      }
      private void normalize() {
          if (newCents &gt; 99) {
              newDollars += newCents / 100;
              newCents %= 100;
          }
          if (getCents() &gt; 99) {
              moneyDollars += getCents() / 100;
              moneyCents %= 100;
          }
      }
  }
  </code></pre>
  
  <p>****I am not allowed to change the MoneyTester Class at all.****</p>
  
  <p>m6 should output original values m7 should output multiplied values.
  I have tried every combination of moneyDollars/Cents and newDollars/Cents, and combinations of Money[] m, and Money[] moneys, that I can think of. Every time m6 is changed along with m7.</p>
  
  <pre><code>public class MoneyTester{
      public static void main(String[] args)
      {
          Money[] m6 = new Money[]{new Money(10, 50), new Money(20, 50), new Money(30, 50), new Money(40, 50)};
          Money[] m7 = Money.multiply(m6, 2);
  
          System.out.print("m6 = (");
          for(int i = 0; i &lt; m6.length; i++)
          {
              if(i &lt; m6.length -1)
                  System.out.print(m6[i] + ", ");
              else
                  System.out.print(m6[i] + ")");
          }
          System.out.println();
  
          System.out.print("m7 = m6 * 2 = (");
          for(int i = 0; i &lt; m7.length; i++)
          {
              if (i &lt; m7.length -1)
                  System.out.print(m7[i] + ", ");
              else
                  System.out.print(m7[i] + ")");
          }
          System.out.println();
  
      }
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>m6 = (21.0, 41.0, 61.0, 81.0)
  m7 = m6 * 2 = (21.0, 41.0, 61.0, 81.0)
  </code></pre>