0
Overload a method
How can I overload a method in a class that is implemented of an interface?
5 Antworten
+ 1
You can make that class as abstract because there is implementation for interface method.
And also
interface library{
public void AddBook();
}
class centeral implements library{
public void AddBook() {
System.out.println("interface method") ;
}
void AddBook(int a){
System.out.println(a);
}
}
Like this you can overload also..
Edit:
In interface abstract methods must be implemented public...
+ 1
Can you show what you trying..?
I don't understand "method implemented of an interface.." ?
Just like any other.. implementation or inheritance not related or affect overloading..
0
for example:
interface library{
void AddBook();
}
class centeral implements library{
void AddBook(int a){
System.out.println(a);
}
}
0
Should I change my subclass or method of that to abstract ?
0
implemented methods must be public
interface Library {
void AddBook();
}
class Central implements Library{
public void AddBook() {
System.out.println("interface method") ;
}
public void AddBook(int a){
System.out.println(a);
}
}