I'm studying Java Silver, so I'll upload it as my memorandum. Since it is a rough memo, details are not described.
interface does not describe the processing content concretely, but implements the method and uses it later. This is effective when you want to change the processing. If you want to implement interface, use implements.
Point
(1) Method cannot be implemented.
(2) Member variables must be constants.
③ Multiple inheritance is possible.
interface A {
String str1 = "Good morning"; String str2 = "Hello"; void A(); }
// Implement the interface and create a class that outputs good morning class B implements A { public void A() { System.out.println(str1); } }
// implements the interface, create a class that output hello class C implements A { public void A() { System.out.println(str2); } }
Recommended Posts