aspose file tools
The moose likes Beginning Java and the fly likes compile-time type checking Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "compile-time type checking" Watch "compile-time type checking" New topic
Author

compile-time type checking

Vatsa dude
Greenhorn

Joined: Apr 29, 2009
Posts: 22
Can anyone please suggest how I can improve compile-time type checking in the following piece of code?

Vatsa dude
Greenhorn

Joined: Apr 29, 2009
Posts: 22
Only solution I can think of is changing <Object, Object> to <String, String> all over the code.. Is that it?
Max Rahder
Ranch Hand

Joined: Nov 06, 2000
Posts: 177
It depends on what types of object you want to store in the map. If you might store anything in the Map, then there is no way to improve it -- what you've defined will store any object/object pair. But, for example, if you know the key is a String, then define the variable as private Map<String, Object> map = new HashMap<String, Object>(); -- the more specific your requirements, the more specific you can be. (By the way, your get() and put() methods don't seem to do anything more than what's provided in the map itself.)
Vatsa dude
Greenhorn

Joined: Apr 29, 2009
Posts: 22
I'm sorry, I might have misunderstood the problem. I had to duplicate a class as a Singleton similar to 'MyCache' below called 'SingletonCache'. Can compile-time type checking be improved in the code below? (Except for changing <Object, Object> to specific type like <String,String>

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: compile-time type checking
 
Similar Threads
Object Caching?
Implementing a class SortedArrayMap that implement Map interface
inner class - ClassNotFoundException
synchronization suggestion needed
Distributed cache across multiple servants using Dynacache - WAS 6.1 in z/OS