import java.util.*;
class Testt
{
public static void main(String args[])
{
int[] arr = {1,3,1,0,5,0,5,0,4,0,2,0,10,40,3,0};
newInts(arr);
}
public static void newInts(int[] arr)
{
ArrayList<Integer> al = new ArrayList<Integer>();
for(int i=0;i<arr.length;i++)
{
al.add(Integer.valueOf(arr[i]));
}
ArrayList<Integer> newList = new ArrayList<Integer>();
Iterator<Integer> it = al.iterator();
while(it.hasNext())
{
Integer in = it.next();
if(!in.equals(Integer.valueOf(0)))
{
newList.add(in);
}
}
for(Integer in:newList)
{
System.out.println(in);
}
}
} |