Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Convert List<Set<String>> to string array

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Convert List<Set<String>> to string array

    Hi all,

    I am a beginner in java and would like to know how to convert List<Set<String>> to an array, so that the output would be without brackets and commas. I have the following part of code:

    List<Set<String>> ls = new ArrayList();
    for (int i = 0; i < ls.size(); i++) {

    System.out.println(ls.get(i));
    }

    output:

    [x, y, z]

    [c, e]

    I tried with toArray(), but I'm getting an ArrayStoringException error.
    Can anyone give some hints?
    Thanks.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,879
    Thanks
    55
    Thanked 2,347 Times in 2,318 Posts

    Default Re: Convert List<Set<String>> to string array

    the output would be without brackets and commas.
    How are you printing it? If you write your own printing code you will have complete control over what is output.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Sorting an object array using string variables from a string array
    By Shadud in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 26th, 2012, 05:50 PM
  2. [SOLVED] [Asking] Convert String to Byte Array
    By ardisamudra in forum Java Theory & Questions
    Replies: 8
    Last Post: October 30th, 2012, 10:58 AM
  3. How to convert String array to Integer array...?'
    By suyog53 in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: September 25th, 2012, 09:50 AM
  4. I need to convert String into array
    By talha07 in forum Collections and Generics
    Replies: 1
    Last Post: October 9th, 2011, 02:58 PM
  5. How can I convert a String to Set<String>? Is it possible?
    By noFear in forum Java Theory & Questions
    Replies: 2
    Last Post: August 25th, 2010, 10:03 AM