title: Why complete Array not printing in Java when it is partially initialized?
body: <p>In the following code, I have resized an array, increased in length by 5 elements. length is displaying correctly. But when I run a loop to display the elements of the array, only initialized elements are displayed. How can I show all the elements?</p>
  
  <pre><code>package arraychallenge;
  
  import java.util.*;
  
  
  public class ArrayChallenge {
  
      public static void main(String[] args) {
  
          Scanner CountScanner = new Scanner(System.in);
          System.out.println("How many integers you have in your list? ");
          int count = CountScanner.nextInt();
          System.out.println("Enter the integers now - ");
          int[] MyArray = getIntegers(count);
  
          System.out.println("Unsorted Array is present here:");
          for (int i = 0; i &lt; MyArray.length; i++) {
              System.out.println(MyArray[i]);
          }
          sortArray(MyArray);
          printArray(MyArray);
  
          resizeArray(MyArray, MyArray.length, 5);
          printArray(MyArray);
  
  
      }
  
      public static int[] getIntegers(int count) {
          Scanner MyScanner = new Scanner(System.in);
          int[] MyArray = new int[count];
  
          for (int i = 0; i &lt; MyArray.length; i++) {
              MyArray[i] = MyScanner.nextInt();
  
          }
          return MyArray;
  
      }
  
      public static void sortArray(int[] MyArray) {
  
  
          int temp;
  
          for (int i = 0; i &lt; MyArray.length; i++) {
  
              for (int j = i+1; j &lt; MyArray.length; j++) {
  
                  if (MyArray[i] &gt; MyArray[j]) {
  
                      temp = MyArray[i];
                      MyArray[i] = MyArray[j];
                      MyArray[j] = temp;
  
                  }
  
              }
  
          }
  
      }
  
  
      public static void printArray(int[] MyArray) {
          System.out.println("Sorted Array is present here:");
          for (int i = 0; i &lt; MyArray.length; i++) {
              System.out.println(MyArray[i]);
  
          }
      }
  
      public static void resizeArray(int[] MyArray, int count, int increase){
          int[] tempArray = MyArray;
          MyArray = new int[count+increase];
          System.out.println("length of MyArray is now " + MyArray.length);
          for (int i = 0; i &lt; count; i++) {
              MyArray[i] = tempArray[i];
  
          }
  
      }
  
  }
  </code></pre>