Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1092
| From | Fred <albert.xtheunknown0@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Trouble with updating reference variables through method calls |
| Date | 2011-09-22 17:42 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <3bf29bca-0e7e-4104-8b55-2e4589dd2ce9@x32g2000prf.googlegroups.com> (permalink) |
Hello,
If this sort of code actually works (which I doubt), I might have to
post some of my actual code for help.
Why is foo1 updated in updateFoo but not in main() (if choice is 1)?
class Bar {
private static void getNewFoo() {
Foo foo = new Foo();
return foo;
}
private static void updateFoo(Foo foo1, Foo foo2, Foo foo3) {
int choice = getChoice();
...
if (choice == 1)
foo1 = getNewFoo();
...
}
public static void main(String[] args) {
Foo foo1 = new Foo();
Foo foo2 = new Foo();
Foo foo3 = new Foo();
updateFoo(foo1, foo2, foo3);
}
Back to comp.lang.java.help | Previous | Next — Next in thread | Find similar
Trouble with updating reference variables through method calls Fred <albert.xtheunknown0@gmail.com> - 2011-09-22 17:42 -0700 Re: Trouble with updating reference variables through method calls Lew <lewbloch@gmail.com> - 2011-09-22 18:01 -0700 Re: Trouble with updating reference variables through method calls Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-22 22:47 -0400 Re: Trouble with updating reference variables through method calls Roedy Green <see_website@mindprod.com.invalid> - 2011-09-22 20:29 -0700 Re: Trouble with updating reference variables through method calls Roedy Green <see_website@mindprod.com.invalid> - 2011-09-22 20:33 -0700 Re: Trouble with updating reference variables through method calls Roedy Green <see_website@mindprod.com.invalid> - 2011-09-22 20:34 -0700 Re: Trouble with updating reference variables through method calls Travers Naran <tnaran@gmail.com> - 2011-09-22 21:27 -0700
csiph-web