The Artima Developer Community
Sponsored Link

Java Answers Forum
Returning Arrays

1 reply on 1 page. Most recent reply: Dec 11, 2002 1:04 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
mary

Posts: 5
Nickname: marymary
Registered: Nov, 2002

Returning Arrays Posted: Dec 11, 2002 12:42 PM
Reply to this message Reply
Advertisement
I have created an array in a method and need to pass this array to another method that creates a GUI. I want to return the array to a TextArea in the GUI and the return method is not working, is there some other methos that I can use??


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Returning Arrays Posted: Dec 11, 2002 1:04 PM
Reply to this message Reply
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] );
   }
}

Flat View: This topic has 1 reply on 1 page
Topic: Inefficiency Problem. Previous Topic   Next Topic Topic: Recursive method

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use