Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create a new HashMap from a HashMap entries of other methods

 
ak swie
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to make a new HashMap from the HashMap entries of the methods. Need to add the entries of a HashMap inside the methods to make a new HashMap.



Can anyone please suggest any way to do that. Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.

I guess you could use reflection. I'd make sure this is what you *really* need to do.
 
ak swie
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.. Could you please help me with reflections. Is it thread safe? How do we implement the same.
 
Ulrika Tingle
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pandeyalok kumar wrote:Can anyone please suggest any way to do that.


Why don't you just do this?


 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you just do this?

Looks like he wants to call only the methods whose name is stored in a map.
 
Ulrika Tingle
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:
Why don't you just do this?

Looks like he wants to call only the methods whose name is stored in a map.


You never know until they tell you.
 
ak swie
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulrika Tingle wrote:
Christophe Verré wrote:
Why don't you just do this?

Looks like he wants to call only the methods whose name is stored in a map.


You never know until they tell you.



I have tried to generalise the actual code here that I am working on.
Will try to post a working code. But please consider this.



totalApplicableMethods gets its value from some predefined condition.
Here in the loop lets say I am calling method1(), method3(). So only they are invoked.
> I want 1=a and 3=c to be in my new HashMap hashTest1.
The loop is working correct. But I am getting hashTest1 empty {} in the end.>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getMethod("method",param)

Here, you are trying to call a method called "method", which does not exist. I don't know where your try/catch are, but you should check that you're not getting an invocation exception (checked exception).
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, how can you call method.invoke(this, args); from a static method ? It's difficult to help without seeing some working code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic