aspose file tools
The moose likes Beginning Java and the fly likes How to make object available for every method? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How to make object available for every method?" Watch "How to make object available for every method?" New topic
Author

How to make object available for every method?

Kacper Szmigiel
Greenhorn

Joined: Sep 18, 2012
Posts: 24
Hello.
I have a short question. How to make object available for every method? For example i want to make object A of class ClassA and run A.make(); in one of ClassB's method. Is it available?
I greet, Kacper.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26496
    
  78

It looks like you are looking to make a public static method. This is a method that is available without instantiating object a. However, it cannot use any of the state in class A.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Kacper Szmigiel
Greenhorn

Joined: Sep 18, 2012
Posts: 24
OK, I'vegot it. ClassB just extends ClassA and ObjectA is declarated as ClassA's variable.
Thanks.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Kacper Szmigiel wrote:OK, I'vegot it. ClassB just extends ClassA


You shouldn't be doing that just to get access to class A's members. You should only do that if a B IS-A special type of A.

and ObjectA is declarated as ClassA's variable.


So you've got this?


If so, that looks very wrong, though it's hard to give concrete advice on how to improve it without a more concrete picture of what you're trying to model and what you want to do with it.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to make object available for every method?
 
Similar Threads
Keep native object alive
Hibernate: object presistent mapping question
Can we dynamically load servlet?
grabage collection
Sharing Objects