• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get the actual value from paramaters Map

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cheers for that,
Worked it out at last, seems a bit long winded though:-

 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!)
 
Screaming fools! It's nothing more than a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic