Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

implementing multiple interfaces

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider that:

 
Ankit Garg
Sheriff
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a question?? You can't implement both interface A and B in one class...
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, but a class can implement multpile interfaces. It's a particular example. Stay tuned!
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well,

This program won't compile. Because you cannot implement both interfaces in class C.
Compiler will be ambigious about method a(). Try to change the argument list in either A
or B, then will allow you to implement both the interfaces, as one method will be correctly
overloaded.

Best Regards,
 
Henry Wong
author
Marshal
Pie
Posts: 21510
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lucas Smith wrote:OK, but a class can implement multpile interfaces. It's a particular example. Stay tuned!



Yes, Java supports implementing multiple interfaces --- but that doesn't mean that you can use the feature to get around overloading rules. You are not allowed to have to methods with the same signature and different return types in a class.

Henry
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. I can notice some bugs in Java.


It is not perfect. The intention behind method a() from those interfaces can be different.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic