About abstract classes in java

I learned because I didn't understand java abstract.

Feature

-Cannot create an instance directly ยท Force subclasses to override -It is necessary to write a constructor in a subclass

sample.java


abstract class Abst_sample {
    abstract void abstractMethod(int num, String str);
    void nonAbstractMethod() {
        System.out.println("Output from non-abstract method");
    }
}
public class sample extends Abst_sample {
    public static void main(String[] args) {
        sample aaa = new sample();   
//After inheriting, it creates its own instance and calls abstractMethod.
        aaa.abstractMethod(3, "Test");
    }
    @Override
    public void abstractMethod(int num, String str) {
        System.out.println("Argument int num= " + num + " /Argument String str= "+ str);
    }
}

I think it's an image that gives an instruction to "use such a method".

When developing with a large number of people, such a function will be needed.

There is no loss to remember.

reference

https://www.sejuku.net/blog/22689

Recommended Posts

About abstract classes in java
[Java] About anonymous classes
About java abstract class
About the idea of anonymous classes in Java
Java abstract methods and classes
Java, abstract classes starting from beginners
How to use classes in Java?
About file copy processing in Java
About returning a reference in a Java Getter
About Java interface
[Java] About Java 12 features
Partization in Java
[Java] About arrays
java (abstract class)
[Creating] A memorandum about coding in Java
Changes in Java 11
Rock-paper-scissors in Java
Something about java
Where about java
About Java features
About standard classes
About Java threads
About Records preview added in Java JDK 14
[Java] About interface
About Java class
About Java arrays
JAVA learning history abstract classes and methods
Continued Talk about writing Java in Emacs @ 2018
About java inheritance
About interface, java interface
[java] abstract class
Pi in Java
FizzBuzz in Java
About List [Java]
About java var
About Java literals
About Java commands
A note on the differences between interfaces and abstract classes in Java
About the confusion seen in startup Java servers
A story about the JDK in the Java 11 era
Try scraping about 30 lines in Java (CSV output)
About var used in Java (Local Variable Type)
Differences in writing Java, C # and Javascript classes
About Java log output
About Java functional interface
Interpreter implementation in Java
Make Blackjack in Java
Java, about 2D arrays
Rock-paper-scissors app in Java
Constraint programming in Java
About class division (Java)
Put java8 in centos7
NVL-ish guy in Java
About [Java] [StreamAPI] allMatch ()
About Java StringBuilder class
"Hello World" in Java
Callable Interface in Java
java classes, instances, objects
[Java] About Singleton Class
Comments in Java source
About classes and instances