This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes I want to know how to use methods furnished below in this program??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I want to know how to use methods furnished below in this program???" Watch "I want to know how to use methods furnished below in this program???" New topic
Author

I want to know how to use methods furnished below in this program???

Aashiq Firnaz
Greenhorn

Joined: Dec 20, 2011
Posts: 3
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36578
    
  16
Welcome to the Ranch

Your question is not clear. You can use the methods by calling them on an instance of your MapInterfaceExample class. But they do nothing useful.

Do you mean how would you implement them?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

Be warned, your current implementation of put will lead to a StackOverflowError. When you call put, it calls put, which calls put, which calls put, etc.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Aashiq Firnaz
Greenhorn

Joined: Dec 20, 2011
Posts: 3
yes Mr Campbell i want to know how to implement them!!!
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10925
    
  12

personally, i would comment all of them out but one, and implement it first. implement it, test it, test it some more, then test it again. Note that when testing, you often have to write 'throw-away' code - code that is used ONLY for testing, but won't then be in your final program.

Which method you do first is sort of dependent on a few things. You can't really test your clear() method if there is nothing in the collection, so it doesn't make sense to implement it first...and Rob is right - your put() method has problems.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I want to know how to use methods furnished below in this program???
 
Similar Threads
Implementing a class SortedArrayMap that implement Map interface
Sorting a HasMap by Values
Implement a data structure that support a sorted Map.
How to remove duplicate from ArrayList?
CallBack Handler Pattern