Character.java
public abstract class Character { //Declared as an abstract class
String name;
int hp;
public void attack(Matango m) {
}
}
** Abstract classes are prohibited from being instantiated by new **
・ It is possible to distinguish between new usage
and inheritance (extends) usage
.
Character.java
public abstract class Character {
String name;
int hp;
public abstract void attack(Matango m); // {}Without;Write (semicolon)
}
** Abstract methods are distinguished as "methods that cannot be determined at this time" ** ・ Clarify "do nothing" and "undecided what to do" ** Can force override ** ・ Eliminate forgetting to "override"
Recommended Posts