import java.util.ArrayList;
import java.util.List;
public class RemoveZeroes
{
public static void main(String[] args)
{
ArrayList a = new ArrayList();
// Add some integers to the array list
a.add(14); a.add(0); a.add(19); a.add(3);
a.add(15); a.add(0); a.add(18); a.add(0);
a.add(44); a.add(0); a.add(51); a.add(78);
// You can also create an Integer wrapper explicitly and add to the array list
a.add(new Integer(83));
// Print the array list - Not the use of the size() method and the get() method
for (int i = 0; i <>
{
System.out.print(a.get(i) + " ");
}
System.out.println();
// Remove the 0 elements
ArrayList aNoZeros = removeZeros(a);
// Print ArrayList a again to see new elements.
for (int i = 0; i <>
{
System.out.print(aNoZeros.get(i) + " ");
}
System.out.println();
}
public static ArrayList removeZeros(ArrayList p)
{
// The easy way: Create a new array list and
// only copy the non-zero numbers into it. Use a for loop
//-----------Start below here. To do: approximate lines of code = 5
//
// Return the newly created array list
}
}