Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7952913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:00:19+00:00 2026-06-04T03:00:19+00:00

how do i retrieve my arraylist into html table? my arraylist: [ 1, 2011-05-10,

  • 0

how do i retrieve my arraylist into html table?

my arraylist:

[
1, 2011-05-10,  1,  22.0, 
2, 2011-05-10,  2,  5555.0, 
3, 2011-05-11,  3,  123.0, 
4, 2011-05-11,  2, 212.0, 
5, 2011-05-30,  1,  3000.0, 
6, 2011-05-30,  1,  30.0, 
7, 2011-06-06,  1,  307.0, 
8, 2011-06-06,  1,  307.0 ]

out.println("<html>");
        out.println("<head>");
        out.println("<title>Counter</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<table border=\"1\">");
        out.println("<tr>");
        for (int i = 0; i < ex.getExpenses().size(); i++) {
            out.println("<td>" + ex.getExpenses().get(i) + "</td>");

            if (i>0 && i%4==0) {
                out.println("</tr><tr>");

            }

        }
        out.println("</tr>");
        out.println("</table>");
        out.println("</body>");
        out.println("</html>"); 

this doesn’t really work, since arraylist starts with 0, it gives me the table that looks like this: enter image description here

how do i get the table that looks like this:

1 2011-05-10  1  22.0
2 2011-05-10  2  5555.0 
3 2011-05-11  3  123.0 
4 2011-05-11  2  212.0 
5 2011-05-30  1  3000.0
6 2011-05-30  1  30.0
7 2011-06-06  1  307.0
8 2011-06-06  1  307.0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:00:21+00:00Added an answer on June 4, 2026 at 3:00 am

    Replace

        for (int i = 0; i < ex.getExpenses().size(); i++) {
            out.println("<td>" + ex.getExpenses().get(i) + "</td>");
            if (i>0 && i%4==0) {
                out.println("</tr><tr>");
            }
        }
    

    with

        for (int i = 0; i < ex.getExpenses().size(); i++) {
            if (i>0 && i%4==0) {
                out.println("</tr><tr>");
            }
            out.println("<td>" + ex.getExpenses().get(i) + "</td>");
        }
    

    By the way. Create separate class Expenses that contains 4 fields. It will be much cleaner and easier to convert this to html. You can write special separate method for converting Expenses to html table row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I retrieve one activity arraylist into another activity and store,update and clear?
I am adding string[] into Arraylist, But when i try to retrieve value from
What I'm doing is storing classes into an ArrayList and retrieve them by its
I have arraylist myorderdata . I want to retrieve this arraylist to one String
I am trying to retrieve the correct value from an ArrayList of objects (.NET
I have saved an ArrayList to the session object. I am trying to retrieve
I retrieve XML from a server, save it into an SD card, then parse
I want to retrieve object data from an ArrayList; public class Form1 { ArrayList
Hi I retrieve data and one Float value from sqlite and return in arraylist:
I want to retrieve an arrayList from the web service in my android activity.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.