I have an abstract class named Customer
and have an MainActivity
extends Activity
, but how do I extend that Customer abstract class in MainActivity?
Asked
Active
Viewed 403 times
-3

ra1ned
- 337
- 5
- 19

Maheshwaran .S
- 23
- 4
-
5Java doesn't support multiple inheritance, Use composition instead... – nobalG Jan 28 '17 at 08:08
-
`Customer extends Activity` and `your_class extends Customer`. or something like the same scenario. – SRB Bans Jan 28 '17 at 08:09
-
By using composition we can able to extend more than one class in java. – Maheshwaran .S Jan 28 '17 at 08:16
-
1Possible duplicate of [Difference between Inheritance and Composition](http://stackoverflow.com/questions/2399544/difference-between-inheritance-and-composition) – Chisko Jan 29 '17 at 01:19
1 Answers
1
In Java, you cannot multiple inherit. Instead of it, you could write:
public class Customer extends Activity{
...
}
public class class_name extends Customer{
...
}
You could use composition. A code which used composition:
public class class_name{
private Customer var_name;
...
}
For more information: Difference between Inheritance and Composition