Results 1 to 4 of 4
  1. #1
    javaworld is offline Member
    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0

    Default How to do looping in collection ?

    Hi,

    My SQL returns the values as like below.

    studentid studentname playid gamename grade prizes
    ----------- -------------- ------- ------------ ------- ---------
    121 bob 1 game1 A 1 and 2
    121 bob 2 game2 C 1 and 3
    121 bob 3 game3 B 4 and 2
    121 bob 4 game4 D 1 and 2
    131 jack 3 gam3 A 1
    131 jack 1 game1 A 2 and 3

    I'm getting the result and iterate the values to display.But in the last column need to display the values as different format.

    Iterator<Search> iterator = products.iterator();

    while(iterator.hasNext())
    {
    Search req = (Search)iterator.next();
    req.getStudentid();
    req.getStudentname();
    req.getgameid();
    req.getgamename();
    req.getgrade();
    req.getprizes() ;
    }

    studentid studentname playid gamename grade prizes
    ---------- -------------- ------- ---------- -------- --------------------------
    121 bob 1 game1 A 1 and 2 and 3 and 4
    121 bob 2 game2 C 1 and 2 and 3 and 4
    121 bob 3 game3 B 1 and 2 and 3 and 4
    121 bob 4 game4 D 1 and 2 and 3 and 4
    131 jack 3 gam3 A 1 and 2 and 3
    131 jack 1 game1 A 1 and 2 and 3

    How to append prizes 4 rows values in first row ? How to loop through here ?
    Please help me.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,602
    Rep Power
    5

    Default Re: How to do looping in collection ?

    Etiquette would indicate that you should at least respond to replies to your previous posts before starting a new one.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    javaworld is offline Member
    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0

    Default Re: How to do looping in collection ?

    Quote Originally Posted by jim829 View Post
    Etiquette would indicate that you should at least respond to replies to your previous posts before starting a new one.

    Regards,
    Jim

    I didn't receive any reply for my question.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,522
    Blog Entries
    7
    Rep Power
    20

    Default Re: How to do looping in collection ?

    Quote Originally Posted by javaworld View Post
    I didn't receive any reply for my question.
    Yes you did; one from Jim and one from Kalata.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. need some help in looping
    By toume in forum New To Java
    Replies: 5
    Last Post: 12-24-2012, 03:15 PM
  2. Looping: Help Please
    By michelle_323 in forum New To Java
    Replies: 5
    Last Post: 10-12-2011, 11:59 AM
  3. Looping
    By Dean29126 in forum New To Java
    Replies: 3
    Last Post: 09-08-2010, 02:01 PM
  4. Help with While and For Looping
    By gmoney8316 in forum New To Java
    Replies: 2
    Last Post: 03-03-2010, 10:54 PM
  5. Looping Help Please
    By JonnySnip3r in forum New To Java
    Replies: 5
    Last Post: 01-31-2010, 05:57 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •