List of things you can't do
Abstract Class | Interface | |
---|---|---|
Can be defined? | No (Can be a mold) | No |
field popular? | Yes | No(Can but force public static final) |
Method | private/public/protected | Forced public |
Inheritance | Only one super class | Any number is OK |
Use Abstract Class if:
--When you want to share an abstract class between similar classes. --When a class inherited from an abstract class has similar methods and fields. --Non-static When using non-final fields.
Use Interface if:
--When an unrelated class defines this interface (for example, Comparable). ――When you don't know who defines it, or when you don't care. --When you want to inherit multiple times.
Reference Abstract Methods and Classes from Oracle
Recommended Posts