java - Provide a method definition with an abstract version before it? -


is posible have:

public abstract void somemethod(); ... public void somemethod() {     // ... } 

in same class? or definition have in child classes?

public abstract void somemethod();  public void somemethod() {    // ... } 

in same class, duplicate method definition. not possible. method differentiated based on method signature , not based on modifier abstract.from official java tutorial:

two of components of method declaration comprise method signature—the method's name , parameter types.the java programming language supports overloading methods, , java can distinguish between methods different method signatures.

question:

or definition have in child classes? 

it can subclass , must concrete subclass in hierarchy.so, first non abstract subclass should provide implementation abstract method. again, java tutorial:

when abstract class subclassed, subclass provides implementations of abstract methods in parent class. however, if not, subclass must declared abstract.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -