Advertisement
Bidderlyn

1

Nov 25th, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1.  
  2. /**
  3.  * Write a description of class TestArray here.
  4.  *
  5.  * @author Dov Triestman
  6.  */
  7. public class TestArray
  8. {
  9.    
  10.  int[] array1 = new int[]{2,3,5,7,9,11,13,17,19};
  11.  int[] array2 = array1;
  12.  
  13.     /**
  14.      * Constructor for objects of class TestArray
  15.      */
  16.     public TestArray()
  17.     {
  18.      System.out.println("Printing array1");
  19.      for(int i=0; i<array1.length; i++)
  20.      System.out.println(array1[i]);
  21.      System.out.println("Printing array2 after changes");
  22.      for(int i=0; i<array1.length; i++)
  23.      {
  24.        if(i%2 == 0)
  25.        {
  26.         array2[i] = i;  
  27.         System.out.println(array2[i]);  
  28.         }
  29.         else
  30.         System.out.println(array2[i]);
  31.      }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement