GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — java-basics/java-programs/RemoveDuplicate.java at master · learning-zone/java-basics Expand file tree/ Copy pathRemoveDuplicate.javaMore file actions 26 lines (21 loc) · 696 Bytes / Copy pathRemoveDuplicate.javaFile metadata and controls26 lines (21 loc) · 696 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 package misc; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; public class RemoveDuplicate { public static void main(String[] args) { ArrayList<String> list = new ArrayList<String>(); list.add("two"); list.add("one"); list.add("three"); list.add("one"); list.add("four"); ArrayList<String> list2 = new ArrayList<String>(new HashSet<String>(list)); // no elements order // ArrayList<String> list2 = new ArrayList<String>(new LinkedHashSet<String>(list)); //To preserve the order of the elements Iterator<String> itr = list2.iterator(); while(itr.hasNext()) { System.out.println(itr.next()); } } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |