Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: Returning Arrays
|
Posted: Dec 11, 2002 1:04 PM
|
|
return is not a method, it is a keyword.
You should be able to return an array from a method, though. Maybe you can post a snippet of your code to illstrate the problem. Be sure and use the java tags mentioned at right in the gray Formatting Your Post box, when you are composing your scintillating prose. I'm sure it will all become clear, then.
Here is a cogent, yet simple sample of a method that returns an array with great alacrity:
class ArrayOfHope
{
public String [] getSomeStuff()
{
String [] stuff = { "'Twas", "brillig", "and", "the", "slithy", "toves" };
return stuff;
}
public static void main(String args[])
{
String [] gotStuff = new ArrayOfHope().getSomeStuff();
System.out.println("Here is the stuff I got:");
for( int i = 0; i < gotStuff.length; i++ )
System.out.println( i + ". " + gotStuff[i] );
}
}
|
|