Results 1 to 3 of 3
Thread: how to format data tables
- 04-19-2011, 07:22 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
how to format data tables
I am very new to java and need to create a data table that shows the growth statistics of a website for three different age groups over 5 years.
I have entered the data into three arrays, group13_24, group25_54, and group55plus, but I cannot figure out how to print the data table in the correct format, with column and row headers.
This is what I have so far for printing out the table:
String[] columnNames = { "13-24", "25-54", "55 +"};
int[][] numbers = { group13_24, group25_54, group55plus };
for (int i = 0; i < numbers.length; i++) {
for (int j = 0; j < numbers.length; j++) {
out.format("%10d", numbers[i][0])
I need my output to look like this:
13-24 25-54 55+
----- ----- -----
2005:
2006:
2007:
2008:
2009:
I have been working on this for a while now but cant seem to figure it out :confused:
-
How about a GUI JTable instead of command-line?
Is there a particular reason e.g. college homework why you need to print the table in command-line?
I say that because your data is already in the correct format to be added to a JTable
- 04-19-2011, 08:11 PM #3
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
Yes its for a project im working on for a class,
ive gotten a little closer, but I still am having trouble
int[][] numbers = { group13_24, group25_54, group55plus };
out.format("%20s%15s%15s\n", "13-24", "25-54", "55+") ;
out.format("%20s%15s%15s\n", "-----", "-----", "-----");
out.println();
for (int i = 0; i < numbers.length; i++) {
out.format("%20s", numbers[i][0]);
for (int j = 0; j < numbers.length; j++) {
out.format("%15s", numbers[j][0]);
}
Similar Threads
-
how to get data from more than two tables based on other
By kishan.java in forum New To JavaReplies: 1Last Post: 03-24-2011, 01:20 PM -
Implementation of Big Dictionary without using data storage in tables
By sanver99 in forum New To JavaReplies: 1Last Post: 01-31-2011, 03:38 AM -
copy defaulttable mode, two different tables , with diff data
By kmm1977 in forum AWT / SwingReplies: 1Last Post: 05-20-2010, 04:27 PM -
How to use one form to submit data to 2 tables on mysql
By kwesiaryee in forum New To JavaReplies: 2Last Post: 10-10-2008, 02:41 PM -
Problem inserting values to MySQL tables from the Data Source Explorer
By tip in forum EclipseReplies: 0Last Post: 12-24-2007, 10:47 AM
Bookmarks