Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
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:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Beginning Java
collection to string array possible!
swetha deshmukh
Greenhorn
Posts: 9
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
can we copy a collection to
string
array to perform sorting?If so how?Is there any other method to sort the elements in a collection
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
I like...
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
There are a number of static sort() methods in the java.util.Collections class that can be applied to any List object. Otherwise, you can use the toArray() method which every collection has, like this:
String[] strings = (String[]) collection.toArray(new String[collection.size()]);
[Jess in Action]
[AskingGoodQuestions]
Georgy Bolyuba
Ranch Hand
Posts: 162
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Use collection which implements SortedSet, SortedMap. (TreeSet, TreeMap)
SCJP 1.4 (100%) Done.<br />SCJD (URLyBird 1.2.3 Started)
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JSTL question --- ${!empty myString}
old for loop vs new for loop
Collections in component interface
Collections
enhanced for loop question
More...