how to solve this Java Array default initialization
<pre><code>public class ApiClass{
 //The below method prints only the user entered values 
 public void printArray(int[] a){
   for(int element : a){
     //ignore because this is the default value when array is created not user entered
     if(element != 0)
     {
       System.out.print(element+"\t");
     }
   }
 }
}

public class Client{
  public static void main(String... args){
    ApiClass api = new ApiClass();
    int[] input = new int[5];
    input[0]= 3;
    input[2]= 2;
    input[3] = 1;
    api.printArray(input);
  }
}
</code></pre>

<p>This is working fine but failing for the 3,2,0 or 0,0,0 or 3,0,1 any input user enters with zero</p>
