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...
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
SCJP 1.4, SCWCD in process
Joined: Feb 24, 2004
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...
Joined: Mar 13, 2004
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 ]