We help IT Professionals succeed at work.

java function for pass values back

lilyyan
lilyyan asked
on
Medium Priority
293 Views
Last Modified: 2010-03-31
Hello,

guess i stocked by a simple question.

Suppose in a java class:
public class testName{

LinkedList list1, list2, list3

 list1 = value1;
 list2 =value2;
 list3 = value3;

private void searchList (list1, list2, list3 ){
LinkedList list1temp = list1,
                 list2temp = list2,
                 list3temp = list3;

// do some process for the three lists, then their there values will be changed

}

my question is: how can i pass the changed values back for list1, list2, list3, if i use return statement , only one value can be returned at one time.

Thanks very much for your reply,

lilyyan
Comment
Watch Question

Senior Web Developer
CERTIFIED EXPERT
Commented:
They are passed by reference and you don't have to return them back to where you call fucntion. They are updated after void function end.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
hi, that's what i'm thinking.

when you say "passed by reference " , this can only be applyed to certain data types, not for primary data type, for example: int, right?
Weiping DuSenior Web Developer
CERTIFIED EXPERT

Commented:
correct
Weiping DuSenior Web Developer
CERTIFIED EXPERT

Commented:
Java manipulate objects by reference, and all object variables are references.

Author

Commented:
clear : )
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.