Results 1 to 2 of 2
Thread: Java collections maps and lists
- 04-11-2012, 09:32 AM #1Member
- Join Date
- Mar 2012
- Rep Power
Java collections maps and lists
3. DO -Create a new class called Kangaroo with an int kangarooNumber thatís initialized in the constructor. Give it a very simple method called hop( ) thatís prints out which kangaroo number this is, and that itís hopping. Create a List and add a group of Kangaroo objects to the List. Now use the get( ) method to move through the List and call hop( ) for each Kangaroo.
4. Modify the above Exercise so you can use an Iterator to move through the List while calling hop()
2. Take the Kangaroo class done in the List exercises and put it in a Map instead, associating the name of the Kangaroo as a String (the key) for each Kangaroo(the value) you put in the table. Get an Iterator for the keySet( ) and use it to move through the Map, looking up the Kangaroo for each key and printing out the key and telling the kangaroo to hop( ). Use generics.
BUt i don't really get it these question as i kind don't understand
- 04-11-2012, 10:14 AM #2
Re: Java collections maps and lists
I'm sure you don't expect someone here to do your homework for you or fill in for your instructor. The questions are quite explicit; if you don't understand them at all you need to start with this Tutorial Trail: Learning the Java Language (The Javaô Tutorials)
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- By Suzanne M in forum Advanced JavaReplies: 0Last Post: 12-24-2011, 03:37 AM
- By mike_ledis in forum New To JavaReplies: 0Last Post: 07-16-2011, 11:24 PM
- By LucasH in forum Advanced JavaReplies: 7Last Post: 05-24-2011, 07:41 PM
- By learn2java in forum Advanced JavaReplies: 6Last Post: 05-01-2011, 04:12 AM
- By shubham.velocity in forum NetworkingReplies: 2Last Post: 11-14-2010, 11:09 PM