Data Structure, Quiz 00

Posted on: Fri, 11/12/2010 - 09:25 By: dae

For each comment line in the form // #0, answer the value of size and elementData. For example, your answer should be

#0 size = 0, elementData =
#1 size = 4, elementData = BANGKOK,PHUKET,BANGKOK,SONGLKA

Please send answer as Email to [email protected] subject: [data] Quiz00 ID include a file named Quiz00_ID.txt

[code lang="java"] public class Main { public static void main(String[] args) { Collection c = new ArrayCollection(10); System.out.println(c.isEmpty()); // #0 (size ==? element data == c.add("BANGKOK"); c.add("PHUKET"); c.add("BANGKOK"); c.add("SONGKLA");
// #1 System.out.println(c.size());

    c.remove("PHUKET");                
    // #2
    c.add("CHIANG MAI");                
    c.add("CHIANG RAI");                
    c.add("CHIANG MAI");                
    // #3
    c.remove("CHIANG MAI");                
    // #4
    c.add("LOEI");                
    c.add("TAK");             
    c.add("PATTAYA");             
    c.add("TAK");             
    // #5
    
    System.out.println(c.contains("PHUKET"));
    System.out.println(c.contains("BANGKOK"));
}

} [/code]

The solution is here