12.6 summary

The final keyword
final indicates "unchangeable, final" means. For modifying variables, methods and classes,
when the final keyword variable modification, when the amount of unchangeable represent variables, constants i.e.
when the final keyword modification method, indicates that the method is not overridden by subclasses, i.e., the final method
when the final key when word modified class that represents the class can not be inherited by subclasses, that is the final class

Internal class, defined in the internal class body of a class of a class, in this case like a "external class" outside, inside the class become inner classes
inside the class can be divided into convenient access to the private member attribute you outside of class, outside of class methods members can access the internal members of the class, but also can directly instantiate classes outside the object inside the outer class, instantiating inner class syntax:
object name = new external object .new inner class constructor

Internal local class
definition: Cub methods defined within the class category called local internal
local internal class can be declared with an access modifier public or private
local scope is defined in the inner class class method declaration in fast
advantage is that the local inner class can be completely hidden from the outside world for
the local inner class can access not only include external members of his class, you can also access the local variables, but only if it is declared as final

Defines an abstract class
abstract class after analysis of problem areas awakened drawn abstraction
before the abstract keyword on the class, well-known class is an abstract class
abstract keyword is placed before the return type of the method, the method is well-known abstract methods, abstract methods there is no way the body
abstract class can not be instantiated using the new keyword can not directly create instances of an abstract class, even if abstract class does not contain an abstract method nor
an abstract class can contain more abstract methods, it may also contain realized the method
is called when an abstract class can contain member variables and constructor, but can not create an instance constructor, you can create an instance of the subclass
definition of abstract class in three ways: direct define an abstract class, or inherit an abstract class but not fully realized the method comprises the abstract parent class; an interface or time, but the full implementation of the abstract method buckle included

Interface:
Interface specification defines a number of classes required to comply with public actions, only the provisions of these classes must provide some method without providing any implementation

java allows a class to implement multiple interfaces, java only supports single inheritance, does not support multiple
[interface] interface name accessor parent interface extends [1, 2 ...... parent interface]

A plurality of interfaces can inherit parent interface but an interface can inherit an interface, the class can not inherit
the interface body may comprise static variables, abstract methods, internal class, the internal interface
implements the interface:
interface can not be instantiated directly, but can use the interface references declare type variable that can be a reference to the instance of the object class that implements the interface, the interface is the main purpose is to achieve implementation class, a class may implement one or more interfaces.
Implements the interface: class name of the class .implentents interfaces Interface 1 ......} {} {

Interfaces, abstract class differences: the interface for multiple inheritance, interfaces, embodies a kind of norm, reflects an abstract class is a template form

implentents implements the interface:
a plurality of class implements interfaces between es

Guess you like

Origin blog.51cto.com/14589602/2457014