2014年1月2日星期四

java interface is a class of it?

My idea is to interface the particularity of an abstract class is a special class .
------ Solution ---------------------------------------- ----
the interface is really a special kind of " abstract class " , the interface where all methods are abstract .
a Java source file can have up to a public interface, if a Java source file defines a public interface, the main file name of the source file name must be the interface same - from this point of view , the interface can be considered as a special category.
------ Solution ---------------------------------------- ----
Interface: initial understanding , can be considered a special abstract class
When an abstract class methods are abstract, then the class can be expressed in the form of interface .
class is used to define the class
interface used to define the interface.
When
interface definitions , format features: constants, abstract methods :
1, the definition of a common interface .
2, a member of the interface has a fixed modifier.
constants : public static final
method : public abstract
Remember : Interface members are public .


Interface: can not create the object because there are abstract methods.
need quilt class implementation , the subclasses of the abstract methods of the interface covering all subclasses can be instantiated.
otherwise sub- class is an abstract class .

class multi- interface can be achieved , but also for the conversion does not support multiple inheritance form . java support multi- realization .
------ Solution ---------------------------------------- ----
say simple point
class is more like a " mold "
while the interface is more interested in a kind of "capacity" , a class that implements the interface must fulfill "contract"

simple example
" bird" can be abstracted as a class, but a lot of things can fly
But the " fly " can be abstracted as a class do ?
Obviously not, "flying" is defined only for the interface is more appropriate !
Just realize it , you can fly , how to fly your thing
------ For reference only ------------ ---------------------------
interface is a standard , it can be said that a special class
---- - For reference only ---------------------------------------
can say focus you need to know the difference between interfaces and abstract classes you will be more in-depth understanding of the .
------ For reference only -------------------------------------- -
looks like it could be so understanding
Such individuals have a personal understanding
------ For reference only --------------------------- ------------

I do not agree with this view , it would be misleading to the concept of classes and interfaces !

------ For reference only ---------------------------------- -----
as a special class
------ For reference only ------------------------ ---------------
interface is standard , all classes that implement it must follow it
------ For reference only ------ ---------------------------------


interface can be " understood " as a special category, of course, in between classes and interfaces are still many differences between the use of
------ For reference only ---- -----------------------------------
interface is a class that is only a limited category. It can not tell you the specific methods , but to tell you who to get there.
------ For reference only -------------------------------------- -
can be seen as a special class
------ For reference only --------------------------- ------------
I just want to know the interface is not a class ?
abstract class me as a classless characteristic body
interface to me as is characteristic of a pure classless body
I mean the essence of the class is not a class just look at the composition of the code ;

------ For reference only ---------------------------------- -----
interface is a specification , the latter to implement the interface in the abstract methods
------ For reference only ----------------- ----------------------
can be understood as describing needs it?

没有评论:

发表评论