Sponsored Link •
|
Advertisement
|
Advertisement
|
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:
Getters and setters are the standard way of accessing a classes variables. In Class1 add the following methods:
Technically, the setter is only needed if you want to set the value of name1 outside of the class containing the variable. In method1, you can set name1 directly, or call the set method above. Now, Class2 can call the getName1() method to get the value of your variable. Jody
Replies: |
Sponsored Links
|