Data Structure, HW01
[code lang="java"] public class TestCollection { public static void main(String[] args) { Collection c = new ArrayCollection(100); System.out.println(c.isEmpty()); c.add("BANGKOK"); c.add("PHUKET"); c.add("BANGKOK"); c.add("SONGKLA");
System.out.println(c.size());
c.remove("PHUKET");
c.multiAdd("PHUKET",3);
c.add("BANGKOK");
System.out.println("BANGKOK: "+c.count("BANGKOK"));
c.remove("PHUKET");
System.out.println("PHUKET: "+c.count("PHUKET"));
c.remove("SONGKLA");
System.out.println("SONGKLA: "+c.count("SONGKLA"));
c.multiAdd("LOEI",0);
System.out.println("LOEI: "+c.count("LOEI"));
} } [/code]
- Log in to post comments