This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes convert collections to string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "convert collections to string " Watch "convert collections to string " New topic
Author

convert collections to string

ssasi kumar
Greenhorn

Joined: Feb 23, 2011
Posts: 26

hi everybody,

i have one doubt how to convert collections(ArrayList,List,vector) to string......





with regards,

sasikumar
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Collections of what ? And how do you intend to separate each item ?


[My Blog]
All roads lead to JavaRanch
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Just call toString() on the collection.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Anooj Narvekar
Greenhorn

Joined: Feb 08, 2011
Posts: 10

Collections override toString method. It internally calls toString of Objects its holding. So if the objects its holding has overriden toString as required, then collection.toString should be what you actually want.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: convert collections to string
 
Similar Threads
How to convert String to org.w3c.dom.Document
String array to arraylist
amount of digits entered(without a tokenizer)....
how to convert Byte to the String
how to subtract two strings