• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 500
  • Last Modified:

Convert Linked List to string

Hey . I have a linked list that can do all of the basic things add remove etc. I was woundering if you can turn a linked list into one string.
Example: Say I have a list of Strings [fred, joe, 56, a, dog, 7, tim, I]
Can I convet that into one String  fredjoe56adog7timI ? Or if you cant do that can I convert into multiple Strings    fred joe 56 a dog 7 tim I
Thanks
0
theldro
Asked:
theldro
2 Solutions
 
ksivananthCommented:
StringBuilder builder = new StringBuilder() ;
for( String str : list ){
  builder.append( str ) ;
}

String result = builder.toString() ;
0
 
anilallewarCommented:
Depends on what you want to do..you can convert the list to an array using the toArray() method.

Check out

http://java.sun.com/javase/6/docs/api/java/util/List.html
0
 
theldroAuthor Commented:
You are to smart
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now