File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I change varible of one class by another class?

 
Larry Lai
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this what you are looking for?
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic