Learned Java for a long time, after a long time to give a classmate to solve a Java problem, it is stuck in the title.
Here's the difference between extends and implements in Java:
1. in the declaration of a class, Create a subclass of a class with the keyword extends. A class declares itself to use one or more interfaces through the keyword implements.
extends is inheriting a class ,  After inheritance you can use the parent class method ,  ; IMPLEMENTS  is to implement multiple interfaces ,  ,  must be rewritten to use the  
2.extends is inherited from the parent class, as long as the class is not declared final or the class is defined as abstract to inherit,JAVA multiple inheritance is not supported, but interfaces can be used to implement, it is necessary to use implements, inheritance can inherit only one class, but implements can implement multiple interfaces, Separate them with commas.
Like what:
Class A extends B implements C,d,e
=========================================================== Implements
Learning for a long time , today finally understand implements, actually very simple , look at the following a few examples OK ~ ~ Some concepts of the interface
Public Inerface Runner {
int ID = 1; void run (); }
Interface Animal extends Runner {
void Breathe (); }
Class Fish implements Animal
{
public void Run () {
System.out.println ("Fish is swimming"); }
public void breather () {
System.out.println ("Fish is bubbing"); } }
Abstract Landanimal implements Animal {
public void breather ()
Wk_ad_begin ({pid:21}); Wk_ad_after (, function () {$ ('. Ad-hidden '). Hide ();}, function () {$ ('. Ad-hidden '). Show ();});
{
System.out.println ("Landanimal is Breathing"); } }
Class Student extends person implements Runner {
......
public void Run () {
System.out.println ("The student is running"); } ...... }
Interface Flyer {
void Fly (); }
Class Bird implements Runner, Flyer
{
public void Run () {
System.out.println ("The bird is Running"); }
public void Fly ()
{
System.out.println ("The Bird is Flying"); } }
Class Testfish {
public static void Main (String args[]) {
Fish f = new fish (); int j = 0;
j = runner.id; j = f.id; }
}
The point of attention of the interface implementation:
A. implementing an interface is all of the methods to implement the interface ( except abstract classes ). B. The methods in the interface are abstract.
C. multiple unrelated classes can implement the same interface, and a class can implement multiple unrelated interfaces. =========================================================== extends and implements the different
extends is inheriting the parent class as long as that class is not declared as final java   inherit, but can be implemented with an interface, which will use the implements implements can implement multiple interfaces, separated by commas   For example  
Class A extends B implements C,D,E//
a class by keyword Implements declare yourself to use one or more interfaces. In the declaration of a class, A subclass of a class is created with the keyword extends.
Class Subclass name extends parent class name implenments Interface name {...}
===========================================================
A = new B (); Results a is a A class can only be accessed by an instance of the A in the method, then and a = new A (); What difference does it have?
========================================================== class B extends A
After inheritance, it is common to define members or methods that are not in the parent class. a = new B ();
This is possible, upload.
A is an instance of a parent class object and therefore cannot access a new member or method defined by the child class. ========================================================== If this definition: class a{int i;
void F () {}
}
Class B extends a{Int J;
void F () {}// overrides void G () {}} and then:
b b = new B ();
b is an instance of a subclass object that can access not only its own properties and methods, but also the properties and methods of the parent class. such as B.i,b.j,b.f (), B.G () are legal. At this point b.f () is the access b in F () A A = new B ();
AIt's used, though.Bthe constructor, but afterupcast, it becomes an instance of the parent class object and cannot access the properties and methods of the child class. A.I,A.F ()is legal, andA.J,A.G ()Non- law. At this point accessA.F ()is to accessBin thef () ========================================================== a = new B ();there are actually three processes in this statement:(1) A;
Declare a as a parent class object, just a reference, unallocated space (2) B temp = new B ();
An instance of a class B object is established by the constructor of class b , which is the initialization
(3) A = (a) temp;
The Subclass Object Temp is converted to the non-parent class object and assigned to a, which is the upload (upcast), which is safe.
After the above 3 processes,a has become an Example of a class.
Subclasses tend to have more properties and methods than the parent class, uploads are only discarded, are safe, and the downcast sometimes increases and is usually unsafe.
=========================================================== a.f () corresponds to the method F () of class B
After invoking the constructor to establish an instance, the entry for the corresponding method has been determined.
So, a although uploaded as a class, but the overridden method Span style= "font-family: ' Times New Roman ';" >f () b Span style= "font-family: the song Body;" > method f () a a1 = new b (); a a2 = new c ();
A1,A2 both are class A objects, but their respective F () are different. This is the embodiment of the polymorphism of the 1 floor. This kind of problem is very clear in "Java programming thought"
Implements is generally implemented as an interface. extends is an inherited class.
Interfaces are generally only defined by method declarations,
Then Java specifically pointed out that the implementation of the interface is justified, because the inheritance has the feeling that the parent class has implemented the method, and the interface is just not the way to implement their own, there is only a declaration, that is, a method header no method body. So you can understand that an interface is a subclass that implements its method declarations rather than inheriting its methods. but the general class method can have the method body, then is called the inheritance is more reasonable.
The introduction package can be used to implement all classes inside a non-interface. So is not the implementation of the interface, this you decide, if you want to use so you are not the implementation, you can not invoke this interface, because the interface is a specification, is a method of the method of the body of the Declaration collection. Let me give an example: the interface can be likened to a protocol, such as I said a protocol is "homicide" then this interface you can use a machete to achieve, as to how to kill a machete can be achieved, of course, you can also use Rob to achieve the killing interface, But you can't kill with a killer interface, because the killing interface is just a function description, a protocol, how to do it, and what to do with his implementation class.
If there is an interface inside a package, you can not implement it. This does not affect your use of other classes.
Implements
implements is a class that implements an interface with a keyword that is used to implement an abstract method defined in an interface. For example: people is an interface in which he has say this method. public interface people () { public say ();} But the interface has no method body. The method body can be implemented only through a specific class. For example chinese This class, it implements people this interface. public class chinese implements people{ public say () {system.out.println (" Hello!
java implements Indicates that the subclass inherits the parent class, such as the class a inheriting class b written and extends different  
Extends, You can implement a parent class, or you can call the parent class to initialize this.parent (). It also overrides the variables or functions defined by the parent class. The benefit is that the architect defines the interface so that the engineer can do it. The overall project development efficiency and development costs are greatly reduced. implements, implements the parent class, which cannot overwrite a method or variable of the parent class. Even if the subclass defines a variable or function that is the same as the parent class, it is replaced by the parent class.
The specific use of these two implementations is to see the actual situation of the project, need to implement, can not modify Implements , only the definition of the interface needs to be implemented, or it can be modified to scale well, with extends .
Excerpt from: Http://wenku.baidu.com/link?url=1ZtGe-5p4z0NoLvX_LXO-cmZQF7Hq8WIA26P3i5yBrcpQrvwBG3GZTOpBrh6kA3ovBTM_ Wewip9gtdiwb1nfupygxp7ravgc6zvtzcyfffo
The difference between extends and implements in Java