Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
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:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
Java in General
getting the value of string array out of object array
jazy smith
Ranch Hand
Posts: 101
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi all,
I have piece of code as mentioned below. I want to parse each
string
array value associated with each object array. (e.g. for obj[0], I need the first string value as "a" and second string value as "ap" ) How would I get them ?
Any idea ?
List list = new ArrayList(); list.add(new String[]{"a","ap"}); list.add(new String[]{"b","ba"}); list.add(new String[]{"c","ca"}); list.add(new String[]{"d","do"}); Object[] obj = list.toArray();
Paul Clapham
Sheriff
Posts: 28399
100
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Just cast an entry of that object array:
String[] first = (String[]) obj[0];
Rob Spoor
Sheriff
Posts: 22849
132
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Or use generics:
List<String[]> list = new ArrayList<String[]>(); list.add(new String[]{"a","ap"}); list.add(new String[]{"b","ba"}); list.add(new String[]{"c","ca"}); list.add(new String[]{"d","do"}); String[] obj = list.toArray(new String[list.size()][]);
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Manipulations with array list.
Iterator problem
problem with retriving values from hashtable
Printing a List backwards
problem with advance for loop
More...