Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Array Methods
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sathushan




PostPosted: 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
Sponsor
sponsor
TerranceN




PostPosted: 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




PostPosted: Tue Dec 07, 2010 11:16 pm   Post subject: Re: Array Methods

[access_level] [static] [return type] identifier ([formal parameters])
wtd




PostPosted: 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




PostPosted: Thu Dec 09, 2010 5:34 pm   Post subject: Re: Array Methods

Yes. Wait, was that for me?
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: