DK
Junior Member
Posts: 23
|
Post by DK on Nov 23, 2001 20:22:08 GMT -5
Is it possible to return a two-dimensional array in a method?
|
|
|
Post by Sky on Nov 23, 2001 20:31:08 GMT -5
yes...just set the return type as a 2d array instead of the usual int or String in the first line of the method
|
|
DK
Junior Member
Posts: 23
|
Post by DK on Nov 23, 2001 22:35:05 GMT -5
thanx :Dfinally got my method to work silly me, found my error. I put something like return map[][] instead of just return map.
|
|
|
Post by Majin_Blues on Nov 25, 2001 16:37:44 GMT -5
does anyone remember how to output a tab?
i remember it's like \t or /t or something but in what format?
e.g. System.out.println("blah \t") or whatever?
|
|
|
Post by gundamf91 on Nov 25, 2001 20:02:11 GMT -5
always \n or \t something not something \t
i think......that's right..
|
|
|
Post by Majin_Blues on Nov 26, 2001 6:43:51 GMT -5
thanks... i hate text output...
if we had more time on this, i woulda started on a GUI
|
|
|
Post by gundamf91 on Nov 26, 2001 19:40:52 GMT -5
actually my prof (today) just showed us something that involved (blahblahblah\t);
so doesn't matter if u put it at the beginning or last (in terms of errors) but i'm sure the order affects the way the stuff is printed out
|
|
|
Post by Majin_Blues on Nov 26, 2001 22:28:30 GMT -5
order does matter for printing purposes... but not for errors... the hardest thing was formatting text on the screen so it looked nice
|
|
|
Post by Yingster on Nov 27, 2001 15:40:40 GMT -5
yes...just set the return type as a 2d array instead of the usual int or String in the first line of the method do u just type something like public Arrays methodname(){ return somearray; } but it doesn't work @_@
|
|
|
Post by bladehunter on Nov 27, 2001 17:22:06 GMT -5
u type:
public (arrayElementType)[][] methodname(){ return somearray; ^ } l here, it is 2-D
|
|
|
Post by Yingster on Nov 27, 2001 18:11:19 GMT -5
thankie just wish they taught this in class
|
|
|
Post by EurasianVixen on Nov 29, 2001 21:55:00 GMT -5
Ok, I used your suggestion, bladehunter. public (String)[][] checkGuess (String array [][], blah ....) { //do stuff to array return array; } and in my main class I have: array = user.checkGuess (array, blah ...); but i get an error when I compile ("illegal start of expression"). How do I fix this??
|
|
|
Post by kermit on Nov 29, 2001 23:41:02 GMT -5
Ok, I used your suggestion, bladehunter. public (String)[][] checkGuess (String array [][], blah ....) { //do stuff to array return array; } and in my main class I have: array = user.checkGuess (array, blah ...); but i get an error when I compile ("illegal start of expression"). How do I fix this?? i'm pretty sure you're not supposed to have parentheses around the word String in your header. WRONG: public (String )[][] checkGuess (String array [][], blah ....) RIGHT: public String[][] checkGuess ( ...etc.)
|
|