View Single Post
  #2 (permalink)  
Old 01-04-2008, 01:49 PM
CaptainMorgan's Avatar
CaptainMorgan CaptainMorgan is offline
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Quote:
Originally Posted by bugger View Post
I am in need of an advice. I am designing my application and want to know when to use abstract class with static methods?

Abstract calls cannot be instantiated. If I don't declare the methods in Abstract class static, how can I call them?

Thanks.
--------
If I understand your question correctly, you simply need to extend the abstract class.

Code:
public abstract class AbstractExample { public static void foo() { System.out.println("Static foo called."); } public void bar() { System.out.println("Non-static bar called."); } }
Code:
public class AbstractCaller extends AbstractExample { public static void main(String[] args) { AbstractCaller ac = new AbstractCaller(); ac.foo(); ac.bar(); } }
Output:
Static foo called.
Non-static bar called.

Hope this helps, see this Sun topic for more info.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Reply With Quote