Describe a thing ————— object
Use a thing ————— object
In Java, a class has a description of himself (that is, a property) and the functionality (i.e., methods) that he can implement.
Appearance (attribute) + behavior (method) = specific Thing (object)
To do what you need to do by calling the object
Classes that store information
Classes that implement functionality
Interface: keyword interface A class that is connected to an interface must implement a method in an interface
Inheritance: The extends subclass inherits the parent class, the subclass can use everything that is not encapsulated in the parent class, and the parent class can also use the subclass's stuff (casts must be cast).
1 Public classASAS {2 Public Static voidMain (string[] args) {3AA a=NewAA ();4A.print ();//invokes the method of the parent class through new-out parent class object. A is the AA type of the parent class (the parent class uses the parent class method)5AA b=NewBB ();6(BB) b). print ();//The method of the subclass is called by the child class object that is out of new. B is the AA type of the parent class (the parent class uses the subclass method)7BB zi=NewBB ();8Zi.print ();//The method of the subclass is called by the child class object that is out of new. Zi is a sub-class BB type (subclass using subclass method)9 }Ten } One A classaa{ - voidprint () { -System.out.println ("Method of the parent class"); the } - } - classBbextendsaa{ - voidprint () { +System.out.println ("Methods of subclasses"); - } +}
Java Object Oriented thinking