File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Can I change varible of one class by another class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can I change varible of one class by another class? " Watch "Can I change varible of one class by another class? " New topic
Author

Can I change varible of one class by another class?

Larry Lai
Ranch Hand

Joined: May 13, 2002
Posts: 44
Hi guy,
Here is a question I want to ask as follow:
I want to use class B to change the name of class A, and then I use class C to access the name of class A. How can I do this?

Thank you
Larry Lai
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ August 09, 2002: Message edited by: Dirk Schreckmann ]
Snigdha Solanki
Ranch Hand

Joined: Sep 07, 2000
Posts: 128
Is this what you are looking for?


Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
It mainly depends on what you are looking for and what your specifications are!
Do A, B and C reside in the same package (if so it is not very interesting)? What is the protection for the attribute name (public, protected, default, private?) ? Is data hiding important (if so you have to add a getter and setter)?
You wrote 'use class B to change the name of class A'. You thus mean that the name is a class and not an instance attribute. So as Snigdha Solank wrote it, the variable 'name' must be static.
W.
 
 
subject: Can I change varible of one class by another class?
 
Similar Threads
passed with 91%, a good start of a long journey
I am new and need help with this plzzzzzzzzzzz
abstract class
91%
Problem calling a simple program