The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2001



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.


How to use get Methods

Posted by Avin Sinanan on November 29, 2001 at 2:32 PM

Ok i was wondering how to use a Get method in the following situation :

1) Lets assume i have a a class called Class1. And Class has a method called method1. Now method1 does not return any values. However within method1 there is a String value. Now i know its strange that method1 produces a string value but it doesn;t return it.. but work with me here.. this is an actual situation i have encountered..Lets say the string value is

String name1 ;

2)Ok now if we have another class called Class2. And we want the Class2 to print name1.
We cannot use System.out.println(name1) because Class2 doesn't recognise the variable name1.

3)How do we use a get method or some method to get this value name1 and transfer it to Class2.

4)Oh and i know how to make a variable global already and well i do not want to use this method becasue it casues some difficulties later on in my program.

5)Oh and thank for helping me out...


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us