Trivial Java question!!

  • Thread starter Chandrashekar Tippur
  • Start date
C

Chandrashekar Tippur

All,

I have a trivial Java question.
I want to change the value of one variable on the calling object. How
do I do that in Java.

For example,
I have a Vector abc in Class A and would like to change this in class
B.
In class A, I instantiate B with abc and down the line I would like to
change the value of abc.

Please let me know if I am not too clear. I will try to reword it. The
code is quite big and I don't want to clutter the message.

Thanks in advance,
Shekar
 
C

Christophe Vanfleteren

Chandrashekar said:
All,

I have a trivial Java question.
I want to change the value of one variable on the calling object. How
do I do that in Java.

For example,
I have a Vector abc in Class A and would like to change this in class
B.
In class A, I instantiate B with abc and down the line I would like to
change the value of abc.

Give B a reference to A.
You can dot that by creating a A field, and accepting an A as an argument in
the B constructor.
 
C

Christophe Vanfleteren

Christophe Vanfleteren wrote:

<snip>

One more thing, these kind of beginner questions are better suited for
c.l.j.help
 
C

C8WALKER

I have a trivial Java question.
I want to change the value of one variable on the calling object. How
do I do that in Java.

For example,
I have a Vector abc in Class A and would like to change this in class
B.
In class A, I instantiate B with abc and down the line I would like to
change the value of abc.

Please let me know if I am not too clear. I will try to reword it. The
code is quite big and I don't want to clutter the message.

Thanks in advance,
Shekar
We dont't do homework here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top