<span style= "font-family:arial, Helvetica, Sans-serif; Background-color:rgb (255, 255, 255); " > Interface Use my main is the code of the dispersion characteristics, but the basis of the dispersion is several, that is, the so-called "high cohesion, low coupling" features, from the point of view of code maintenance, get Oh great improvement, below is a small section of my typical interface using instance code:</span>
<span style= "font-family:arial, Helvetica, Sans-serif; Background-color:rgb (255, 255, 255); " ></span><pre name= "code" class= "java" >package com_5;interface computer{public Void Open ();p ublic void Close ();} public class Inter {/** * @param args */public static void main (string[] args) {S1 P1 = new S1 ();p 1.open (); s2 p2 = new S2 ( );p 2.close ();}} Class S1 implements Computer{public Void Open () {System.out.println ("S1 computer Boot");} public void Close () {System.out.println ("S1 computer shuts Down");}} Class S2 implements computer{public void Close () {System.out.println ("S2 computer Off");} public void Open () {System.out.println ("S2 computer");}}
Interfaces do not require entities, but as long as the interface is connected, it is necessary to complete the interface method, which is the main feature of the interface.
Second, interfaces cannot be inherited.
Basic use of the Java interface