newcoder1010 Posted December 21, 2021 Share Posted December 21, 2021 Hello class base{ } class A extends base{ } class B extends base{ } class C extends B,A{ } I am getting an error "Syntax error on token ",", . expected" on this line class C extends B,A{ How can class C extend class B and A? Thanks! Link to comment Share on other sites More sharing options...
Ingolme Posted December 22, 2021 Share Posted December 22, 2021 Java does not permit extending multiple classes. If you want the functionality of multiple classes, it's best to make instances of those classes as properties of your object and then use properties and methods of those instances. class C { public A a; public B b; } Link to comment Share on other sites More sharing options...
newcoder1010 Posted December 29, 2021 Author Share Posted December 29, 2021 Thank you! Link to comment Share on other sites More sharing options...
akratirawat Posted July 1, 2022 Share Posted July 1, 2022 class A { public void test(){} } class B { public void test() {} } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now