Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Converting String array to String

807588May 28 2009 — edited May 31 2009
Hi Guys,

I have a String array having String "data" ofcourse. I was just wondering if instead of looping through each index as shown in the code below, can I copy all the "data" strings present into a single String. e.g Suppose I have data[0]="a", data[1]="b", data[2]="lmn". Can I get ablmn without looping through the array? I tried java.util.Arrays.toString(data) but it did not work. Any ideas? Is making "data" variable vector is the only solution. Also, is there any way of dumping String array contents into a vector possible if vector is the only solution to the problem. Hoping to hear from you guys soon.

Thanks.

String[] data;

for(int i=0;i<data.length;i++)
{	
	System.out.println(data);
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 28 2009
Added on May 28 2009
17 comments
853 views