This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
RE : Take a Look at my prog and check out the error
Posted by Pierre on June 18, 2001 at 6:22 AM
> I added the components this way > Checkbox b=new Checkbox("Checkbox_1"); > add(b); > Checkbox b=new Checkbox("Checkbox_1"); > add(b); > Checkbox b=new Checkbox("Checkbox_1"); > add(b); > > the output was three checkbox were created? > > Now my doubt is can the applet take in the same reference name (i.e) i gave in the same reference "b" for all three checkbox component? > can we do it this way ? > can anyone explain me the logic of this? one you make a b=new Checkbox("Checkbox_1"); b is a reference to a new object when you do add(b) you add a reference to the "current" b to you're applet. in you're example b=new Checkbox("Checkbox_1"); | b has a refernce to a checkbox add(b) | the applet keeps a reference to the checkbox b=new Checkbox("Checkbox_1"); | b is now a ref to another check add(b) | the applet now keeps a ref to the first and the second
Replies:
|