I want to define a variable that implement 2 interface. Imove and Ijump are 2 interface.
class b implements Imove,Ijump {...}
class a implements Imove,Ijump {...}
Imove,Ijump player = new a();
Imove,Ijump player = new b();
player.Jump();
player.Move();
interface can inherit from (multiple) other interface with extends.
Define third interface.
interface MoveAndJump extends IMove,IJump{};
Use that third interface.
MoveAndJump player = new a();
player.jump();
player.move();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With