This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes return statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "return statements" Watch "return statements" New topic

return statements

James .D.Johnstone

Joined: Dec 08, 2004
Posts: 20
I have a programming problem where I have to construct a class using constuctors and methods .One of the methods contains an array of ints which has to be called from another class using the main method how do I pass a value to another class if the method with the array has to be declared void ? i think this is the case as return statments can only return single values

thankyou for your input in advance
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
You can return a reference to an array or accept an argument that is an array reference and change the elements of the array.

Try this:

or this:

[ February 06, 2005: Message edited by: Mike Gershman ]
[ February 06, 2005: Message edited by: Mike Gershman ]

Mike Gershman
SCJP 1.4, SCWCD in process
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: return statements
It's not a secret anymore!