Hello everyone!
I just recently started learning Java and got stuck with the rectangular arrays.
I was wondering if there is anyone that could briefly tell me the easiest way to display such array. A simple example would be greatly appreciated!
Thanks!
-f-
Rectangular Arrays
Page 1 of 17 Replies - 2305 Views - Last Post: 17 April 2003 - 12:03 PM
Replies To: Rectangular Arrays
#2
Re: Rectangular Arrays
Posted 13 April 2003 - 02:17 AM
Can you please explain what you mean with 'rectangular'???
I suppose you mean 2-dimensional arrays...
I suppose you mean 2-dimensional arrays...
#3
Re: Rectangular Arrays
Posted 14 April 2003 - 07:24 PM
fijufiic, on Apr 12 2003, 10:31 AM, said:
the easiest way to display such array
It depends on what is in the array...
#4
Re: Rectangular Arrays
Posted 15 April 2003 - 01:44 AM
<digress> is anything happening with your web site cyberscribe ??? </digress>
This post has been edited by arniie: 15 April 2003 - 01:44 AM
#5
Re: Rectangular Arrays
Posted 15 April 2003 - 10:54 AM
arniie, on Apr 15 2003, 12:44 AM, said:
<digress> is anything happening with your web site cyberscribe ??? </digress>
It's ... um... gestating at the moment:
http://www.peakepro.com
#6
Re: Rectangular Arrays
Posted 16 April 2003 - 08:20 AM
Ok, yes, it is 2-dimensional array... I have to prompt user for width, total numbers to be displayed and the value of the first number of the array to be displayed.
So, if I enter:
width: 5
count: 12
start: 22
the output should look like:
22 23 24 25 26
27 28 29 30 31 ---> This display is what I have problem with!
32 33
Thanks!
-f-
So, if I enter:
width: 5
count: 12
start: 22
the output should look like:
22 23 24 25 26
27 28 29 30 31 ---> This display is what I have problem with!
32 33
Thanks!
-f-
#7
Re: Rectangular Arrays
Posted 16 April 2003 - 10:00 AM
so if you have the array filled then just set up some for loops and run through it
I didnt account for the missing elements on the end of the array, but you could put some sort of if statement in there to see if there is a value
for (i = 0; i < the # of rows; i++){
for(j = 0; j < the # of columns; j++) {
System.out.print(yourArray[i][j] + " ")
}
enter a newline here
}
I didnt account for the missing elements on the end of the array, but you could put some sort of if statement in there to see if there is a value
#8
Re: Rectangular Arrays
Posted 17 April 2003 - 12:03 PM
I finally got it to work!
Thanks!
-f-
Thanks!
-f-
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|