[6471] in java-interest

home help back first fref pref prev next nref lref last post

Re: Multidimensional Arrays

daemon@ATHENA.MIT.EDU (Sumanth Rajagopal)
Sun Mar 31 16:37:39 1996

Date:         Sat, 30 Mar 1996 16:04:15 -0500
Reply-To: Java Interest <JAVA-INTEREST@JAVASOFT.COM>
From: Sumanth Rajagopal <sumanth@CIS.UFL.EDU>
To: Multiple recipients of list JAVA-INTEREST
              <JAVA-INTEREST@JAVASOFT.COM>

 -> Date:         Fri, 29 Mar 1996 15:52:12 -0500
 -> From: Lou Fasulo <fasulol@POSTOFFICE.PTD.NET>
 ->
 -> I am writing a program where I need a multidimensional array.  I
 -> realize that Java does not support this but you can simulate it with
 -> the:
 ->                 type varname[][]
 ->
 ->         However, when I try to declare and initialize it I get a
 -> statement expected error.
 ->
 ->         I would like to create a loop that initializes an 8x8 matrix
 -> with different values for each "location"  How can I do this??
 ->

try this:

this reply doesn't look very professional but I hope it will drive home
the point.


type[][] varname = new type[8][8]

....
...

for (i=.....)

for (j=.....)


varname[i][j] = new type();  // where type() is the constructor of u'r type.

varname[i][j] = x;  // where x = the value corresponding to "type".

-----
This message has been forwarded via the JAVA-INTEREST
mailing list.  In order to unsubscribe from this list, send a message to
listserv@javasoft.com with the command 'signoff JAVA-INTEREST' in
the message body (not in the subject line).

-----
This message has been forwarded via the JAVA-INTEREST
mailing list.  In order to unsubscribe from this list, send a message to
listserv@javasoft.com with the command 'signoff JAVA-INTEREST' in
the message body (not in the subject line).

-----
This message has been forwarded via the JAVA-INTEREST
mailing list.  In order to unsubscribe from this list, send a message to
listserv@javasoft.com with the command 'signoff JAVA-INTEREST' in
the message body (not in the subject line).

home help back first fref pref prev next nref lref last post