Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)
I have created an ArrayList and I want to get the output as String. Can anyone help me with this?

1 Answer

0 votes
by (26.7k points)

With the help of StringBuilder, you can able to do that in more feasible way. You can prefer the below code as a reference:

ArrayList<String> list = new ArrayList<String>();

list.add("one");

list.add("two");

list.add("three");

StringBuilder sb = new StringBuilder();

for (String s : list)

{

    sb.append(s);

    sb.append("\t");

}

System.out.println(sb.toString());

I hope this will help.

Want to become a Java Expert? join Java Training now!!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...