/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; import java.util.ArrayList; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { ArrayList<Object> al = new ArrayList<Object>(); al.add("java"); al.add('a'); al.add('b'); al.add('a'); al.add("java"); al.add(10.3); al.add('c'); al.add(14); al.add("java"); al.add(12); for(int i=0;i<al.size();i++){ for(int j=i+1;j<al.size();j++){ if(al.get(i).equals(al.get(j))){ al.remove(j); j--; } } } } }
Standard input is empty
Before Remove Duplicate elements:[java, a, b, a, java, 10.3, c, 14, java, 12] After Removing duplicate elements:[java, a, b, 10.3, c, 14, 12]