There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Russy Bond wrote:Thanks Fred. I know that would work but my requirement is such that I want to access a value that has already been set and I do not want to set it again the second time.
Russy Bond wrote:For e.g you could think of loading all the properties file and set the property values in ClassA. Now from a different ClassB, I want to get a property value (that has already been set in ClassA).
Joanne
Russy Bond wrote:Sorry about not adding more details. Actually I am using a @BeforeClass annotation of TestNG which makes sure myTestMethod gets definitely invoked and the name variable also gets set. I am able to print the value in TestA class. My only problem is now how to print this name or make the getter name print the value in TestB class. I hope I am being clear this time.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Russy Bond wrote:Thank you Fred. That was a good example. I get the mistake now. I think if I do not want to set the name through the new instance, the only way out for me is to declare the getName method as static and call it by TestA.getName().
Joanne
Maybe, Joanne? Maybe? Surely you meant, definitelyJoanne Neal wrote: . . . maybe someone will be able to see your problem.
Campbell Ritchie wrote:I know people will disagree with me but I like the idea mentioned in this how to write javadoc comments link that you must write a constructor for every class.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:You cannot write constructors for anonymous classes. As far as I can tell they use constructors from the named class being extended and would only require a default constructor if the class has no constructor or you instantiate an interface
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |