0

Overload a method

How can I overload a method in a class that is implemented of an interface?

21st May 2020, 8:31 PM
Zahra
5 ответов
+ 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...
21st May 2020, 9:03 PM
Jayakrishna 🇮🇳
+ 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..
21st May 2020, 8:42 PM
Jayakrishna 🇮🇳
0
for example: interface library{ void AddBook(); } class centeral implements library{ void AddBook(int a){ System.out.println(a); } }
21st May 2020, 8:49 PM
Zahra
0
Should I change my subclass or method of that to abstract ?
21st May 2020, 8:57 PM
Zahra
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); } }
22nd May 2020, 5:09 AM
zemiak