aspose file tools*
The moose likes Beginning Java and the fly likes Forcing horizontal display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Forcing horizontal display" Watch "Forcing horizontal display" New topic
Author

Forcing horizontal display

Gjorgi Var
Ranch Hand

Joined: Feb 24, 2004
Posts: 85
How can I force horizontal display of results of multiplication between numbers (for example)1 through 12... results are stored in a two-dimensional array and the requirement is that the display of those results is in a table... in the darkness of the command prompt... have tried typical escape character tricks, but they didn't trick the dark screen of DOS...
Imports allowed only from util...
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi Gjorgi Var
Is it shown in the following?
1 2 3 4 5 6 7 8 9 10 11 12
2 4 6 8 10 12 14 16 18 20 22 24
3 6 9 ...............
.................
Using two-dimensional array to store the above result?


Francis Siu
SCJP, MCDBA
Gjorgi Var
Ranch Hand

Joined: Feb 24, 2004
Posts: 85
Actually it's more like this:
1 2 3 4 5 6...12
1 results result result
2 result...
3
4
.
.
12
Yeah, what a sloppy beginner...
[ April 09, 2004: Message edited by: Gjorgi Var ]
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
I'm not sure if this answers your question, but you can display a two dimensional table as follows:

Be sure your DOS window is wide enough to hold a row of your array. This is controlled by the properties->layout tab of the icon for the MS-DOS window.
You can save screen width by using " " instead of "\t" but that means the columns won't always line up.
By the way, if you don't like the white on black color scheme, change it in the properties->colors tab


Mike Gershman
SCJP 1.4, SCWCD in process
Gjorgi Var
Ranch Hand

Joined: Feb 24, 2004
Posts: 85
After compiling Mike's code (prevously put it in class framework and all that) I get NullPointerException (I guess for missing the "x[i][j]=i*j" part). But even after corrections both on the code and on the DOS window settings, layout is stil vertical...
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Did you notice where I used System.out.print instead of System.out.println? System.out.print prints and stays on the same line. System.out.println also prints but it adds a '\n' so the next output will go on the next line.
As for the NullPointerException, you said in your first note that you were printing from a two-dimensional array. You probably have a problem in setting up the array.
Remember that you must first declare a named reference to two-dimensional array objects, then create a two-dimensional array object consisting of references to one-dimensional array objects and point the reference to it, then create each one-dimensional array object and point the references in the two-dimensional array object to it, then assign your values to each element of the completed two-dimensional array. There are ways to perform these steps into fewer statements, but they must all happen.
Your textbook should have a good example. If you like, post your code and we'll give you our best advice.
[ April 10, 2004: Message edited by: Mike Gershman ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Forcing horizontal display