About Java interface

Java interface features

There are two features of the interface:

--The interface cannot have instance fields (instance variables) --Cannot implement concrete methods (methods that are not abstract methods)

interface has no instance field

In the interface, when you try to declare a field, it is treated as if you declared a constant like public static final.

Unable to implement concrete method

Only abstract methods can be defined, and when an interface is implemented, the abstract method must be overridden when an instance is created.

bonus

Be careful when creating classes instead of interfaces for commonality of each class. If each class is a subclass of some kind, it is not possible to inherit what was made into a common class. Because in Java, you can only have one superclass. If it is an interface, it is possible to implement multiple.

Recommended Posts

About Java interface
[Java] About interface
About interface, java interface
About Java functional interface
java (interface)
[java] interface
[Java] About Java 12 features
[Java] About arrays
[Java beginner] About abstraction and interface
Something about java
Where about java
About Java features
About Java threads
About Java class
About Java arrays
[Java] Functional interface
About java inheritance
About List [Java]
About java var
About Java literals
About Java commands
About Java log output
Java, about 2D arrays
About class division (Java)
Commentary: About the interface
About [Java] [StreamAPI] allMatch ()
About Java StringBuilder class
Callable Interface in Java
java standard functional interface
[Java] About Singleton Class
About Java method binding
[Java] About anonymous classes
About method splitting (Java)
[Java Silver] About initialization
JAVA learning history interface
About Java Array List
About Java Polymorphism super ()
About inheritance (Java Silver)
About Java String class
About Java access modifiers
About Java lambda expressions
About Java entry points
About Java 10 Docker support
Personal summary about Java
[Java] About enum type
Java learning memo (interface)
All about Java programming
About java abstract class
A note about Java GC
What I researched about Java 8
About an instance of java
JAVA learning history interface inheritance
[Java] Functional interface / lambda expression
What I researched about Java 6
[Gradle] About Java plug-in tasks
interface
About Java variable declaration statements
What I researched about Java 9
[Java] About try-catch exception handling
About Java class loader types
Check Java9 Interface private methods