Re: How do I get a String[] from a Map<String,Object> keys ?
- From: "Steve W. Jackson" <stevewjackson@xxxxxxxxxxx>
- Date: Mon, 02 Jul 2007 09:10:22 -0500
In article <1183385127.693826.270170@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Jerome Eteve <jerome.eteve@xxxxxxxxx> wrote:
I all.
I have a
Map<String,Float> foo = ....
And the following line of code a couple of instructions after:
String[] fields = (String[])(foo.keySet().toArray()) ;
But at the runtime, I have a class cast exception telling me that it's
not possible to cast an Object down to a String.
How can I do to have an array of strings from the foo map key set ?
Thanks for your help.
Revisit the API and you'll find that the Set method toArray() explicitly
returns an Object array. But there's an alternative method which
returns an array of the type used in the Set. Try that one.
--
Steve W. Jackson
Montgomery, Alabama
.
- References:
- How do I get a String[] from a Map<String,Object> keys ?
- From: Jerome Eteve
- How do I get a String[] from a Map<String,Object> keys ?
- Prev by Date: HELP: Java ssh library - unstable connection
- Next by Date: Re: Why the 127.0.1.1?
- Previous by thread: How do I get a String[] from a Map<String,Object> keys ?
- Next by thread: Re: How do I get a String[] from a Map<String,Object> keys ?
- Index(es):
Relevant Pages
|