• Post Reply Bookmark Topic Watch Topic
  • New Topic

HashMap value  RSS feed

 
vin Hari
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
Iam usong Hash map for my project , my question is for a given key
iam getting the corresponding value,but it will be in [],
but iwant only value without brackets how to do is there any solution.

please help me soon,
thanks in advance.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is intermediate, at most, and really is beginner.

Given:

Collection collector;

[] element = collector.get() have to know the type of the element contained in the array, then you would code the above as:

element[position]

we really need a few more details about what exactly is in the array:

An array cannot contain aa/bb/cc/dd/ee/ff unless it is a charcter array, in which case you need to think of a better way to store your data.
 
vin Hari
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you,
For reply the symbol i have shown [] was not array in the previous case it was a pattern means when you retrieve a value from the map values will be in [value1,value2,....]which not a array all the elements of map. what i wanted was only values without [](brackets) whether it is possible.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a string like "[one,two,three]" and you want a string like "one,two,three" ? You can pull out parts of a String with substring(). This will give you a new string without the left [ ...

String newString = oldString.substring(1);

See if you can write another substring to remove the rightmost ]

String newString = newString.substring( ... )
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!