The Artima Developer Community
Sponsored Link

Java Buzz Forum
How to Convert Array to Collection, Set and List in Java with Example

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
How to Convert Array to Collection, Set and List in Java with Example Posted: May 27, 2013 8:20 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: How to Convert Array to Collection, Set and List in Java with Example
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
In this example we will learn how to convert an String array to Collection, Set or List in Java. This knowledge of converting array to Collection can be really useful to any Java developer, as most of legacy code tend to use array, which means you either need to pass them your input as array or they return result as array. Since newer Java code prefer Collection over array, which they should, because of flexibility offered by Collection classes, we often need to convert Array into different Collection classes e.g. List, Set or simply Collection. I have shown couple of techniques for converting array to arraylist, which equally applicable, when it comes to convert Array to List in Java. In this article, we will go couple of steps further and not only learn converting array to List, but also array to Set and array to Collection in Java. Well, it's only one method, which you need to know, Arrays.asList(), which accepts an array and return a List, later you can convert this List into any other Collection, by using copy constructor provided by Collection classes.
Read more ยป

Read: How to Convert Array to Collection, Set and List in Java with Example

Topic: First look: Android Studio eclipses Eclipse Previous Topic   Next Topic Topic: Atlassian gives Jira bug tracker a new UI and a speed boost

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use