java (abstract class)

Declaration of a class containing abstract methods

abstract = abstract method

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.

Declare attack () as an abstract method

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

java (abstract class)
[java] abstract class
About java abstract class
Java learning memo (abstract class)
[Java] Class inheritance
java Scanner class
Java HashMap class
[Java] Nested class
Java anonymous class
About Java class
[Java] Object class
Java local class
Java abstract modifier [Note]
About class division (Java)
About Java StringBuilder class
[Java] About Singleton Class
abstract (abstract class) and interface (interface)
Java inner class review
Java class type field
Java programming (class method)
About Java String class
Java programming (class structure)
Interface / abstract class / override
Why java allows final class A {abstract class B {}}
[Java] Integer wrapper class reference
Advanced inheritance abstract, interface -java
Java memo (standard class) substring
Java tips --StaticUtility class modifier
Java inflexible String class substring
Java memo (standard class) length
[Implementation] Java Process class notes
About Java class loader types
Example of using abstract class
How to use java class
[Java] Comparator of Collection class
Java class definition and instantiation
Java
Summary of Java Math class
[Java] What is class inheritance?
About Java class variables class methods
Use of Abstract Class and Interface properly in Java
About abstract classes in java
Java
Java abstract methods and classes
Why implement an abstract class (Abstract)
[Java basics] What is Class?
Create an immutable class with JAVA
Difference between interface and abstract class
Call Kotlin's sealed class from Java
Java, abstract classes starting from beginners
[Java] Object-oriented syntax --class method / argument
Various methods of Java String class
[Java] Memo for naming class names
How to disassemble Java class files
Kotlin Class to send to Java developers
StringBuffer and StringBuilder Class in Java
How to decompile java class files
[Java] How to use LinkedHashMap class
[JAVA] Difference between abstract and interface
java (use class type for field)
Java source code reading java.lang.Math class