Array Methods
Author |
Message |
sathushan
|
Posted: Mon Jun 07, 2010 5:19 pm Post subject: Array Methods |
|
|
I was wondering if someone can help me fix this problem. I am trying to call a method with an array inside it but I think i'm doing it wrong. any assistance is appreciated.
I have this initialized this 2D array in my main class; it is a 3 by 3 array
char[][] outline={{' ',' ',' '},{' ',' ',' '},{' ',' ',' '}};
What I want is to show the below array on the screen. The is the method I want to call is below.
public static void showBoard(char board[][])
{
for(int x=0;x<3;x++)
{
for(int y=0;y<3;y++)
{
System.out.print("["+ board[x][y] +"]");
}
System.out.println();
}
}
How would i call this in my main method?
outline(displayBoard); ? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
TerranceN
|
Posted: Mon Jun 07, 2010 5:26 pm Post subject: RE:Array Methods |
|
|
When you call methods it goes like this: methodName(Parameters);
So when you call that method it would be: showBoard(outline); |
|
|
|
|
 |
SS1389
|
Posted: Tue Dec 07, 2010 11:16 pm Post subject: Re: Array Methods |
|
|
[access_level] [static] [return type] identifier ([formal parameters]) |
|
|
|
|
 |
wtd
|
Posted: Wed Dec 08, 2010 12:51 am Post subject: RE:Array Methods |
|
|
Please note that arrays in Java are not objects. You do not call methods on them, though as you seem aware, you can pass them to other methods as arguments. |
|
|
|
|
 |
SS1389
|
Posted: Thu Dec 09, 2010 5:34 pm Post subject: Re: Array Methods |
|
|
Yes. Wait, was that for me? |
|
|
|
|
 |
|
|