output a set or a list

Posted on 2006-04-12
Last Modified: 2010-03-31
Hello experts,

 when I try print a set or a list:


 the output looks like:

  [A, B, C]
 is there any other way to print it ? I want the output look like:
Question by:meow00
    LVL 92

    Accepted Solution

    Iterator i = set1.iterator();
    int n = 1;
    while(i.hasNext()) {
    LVL 30

    Assisted Solution

    For a list you can use a loop:

    for ( int i = 0, count = list.size () ; i < count ; i ++ )
     System.out.println ( ( i + 1 ) + "." + list.get ( i ) ) ;

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    maxMirror challenge 10 69
    scoresClump  challenge 31 87
    Increment alphanumeric sequence 6 57
    json example 39 81
    For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now