File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Returning an arrray from a method?

 
ione walker
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a method (getArray) that does some stuff.
(I can't send the code as it is Cattle Drive Stuff)
it generates an array.
I can get it to sent the array to the screen using
System.out.println( intData( i ) );
But I do nto seem to be able to get the
array outside the method.
I am sure that I am doing something wrong
that is a matter of not understaning the syntax
well enough.
Cindy, I am sending you the code.
could you take out the tell-tale stuff.
Thank You Very much.
=========
(code removed by Cindy)

------------------
=======================
Ione Walker
walkeri@usa.net
========================
[This message has been edited by Cindy Glass (edited May 16, 2001).]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
return intData[];

Try just saying "return intData". You only use the [] stuff during the declaration. The variable name does not include it.
 
Art Metzer
Ranch Hand
Posts: 241
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should give you some help with the syntax of arrays in methods, Ione.
Please forgive the fact that my contrived class doesn't really do anything:

In particular, notice that:
1) If a method returns an array, then the return type in the method signature has to indicate an array ("public int[] gimme() {...}").
2) In the return statement of your method, just return the name of the array: no brackets. ("return temp;", not "return temp[];").
Hope this helps, Ione.
Art
[This message has been edited by Art Metzer (edited May 16, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic