• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get the actual value from paramaters Map  RSS feed

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, for the love of God what were the people at Sun thinking when they did this?!...


I am trying to do the simplest of things that I'm sure people do on a day-by-day basis, but for some reason the people of Sun seem to have made it as compicated as can be!



All I want is the ACTUAL value of the entry, not this [Ljava.lang.String;@e15497 value. I want to see "Hello I am an actual value".
When I debug, I can see this value under value = "Hello I am an actual value", but run the code and I just get [Ljava.lang.String;@e15497.

Why have they done this? And how do I get the actual value of the Entry?
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't know how to output the value, because there is no single value. That output indicates that the value is actually a String array. So cast it to a String[] and then output it however you want it outputting.

Incidentally, there is a slightly easier way of writing that loop:
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers for that,
Worked it out at last, seems a bit long winded though:-

 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that arrays do not override the Object#toString() method.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way. That if (strArray != null) check isn't required. If it's null then it will never pass the instanceof check. But you probably should check for empty arrays with strArray.length == 0.

(Empty arrays may be impossible due to the way the parameter map is created, but I'd prefer not to rely on that!)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!