some understanding about Java
2006-09-29 02:29
375 查看
I began to read Java second time,during this time,I found that I've some different thinking with the first time.I neither know whichi is right,so I hope somebody can reply it can help me make sure it. Thanks a lot.
1.In the superclass, there is a abstract method,and the subclass isn't declare the mothed which is samed with superclass abstract the JVM will not compile.You need declare the subclass use abstract keyword,or you need to implement the abstract method in subclass.In other words,the subclass become the abstract class.
2.When use the abstract? When you are doing OOP,the method which is all exist between instance and instance and put them into the superclass.But there is no idea about what to the method should do,you can duplicated use the code by abstract and extends .For instance, there is a Animal class,and it have a sleep method,but it has different behaviors,maybe lie,hang or something like that,this time you can use abstract and extends to implement the relative sleep method by subclass.And when a class be signed the abstract keyword it can't instance.
3. Interface is important,it is good for communicate between blocks.When you set a interface,you create a class to implement it,you must run all abstract method and the method all use public keyword.You also can use it between two blocks,one class invoke the interface and the other implement the interface.But on this time the interface can not instance an object, so you must use its calling class instance an object,and let the reference instance assign to the interface's parameter.And it also can be extended,even it has more than one interface.And class can have many interfaces,when a class extends another class,the subclass can extends interfaces,just like subclass inherit method and variable from superclass.
Above these is only my thinking,maybe something right or not. And there are something i didn't refer,i'll do that later.I'm looking for your suggestion.And now,I also thank the people who give me hands,thank you so much,and have a good holiday,have a nice Middle-autumn day!
1.In the superclass, there is a abstract method,and the subclass isn't declare the mothed which is samed with superclass abstract the JVM will not compile.You need declare the subclass use abstract keyword,or you need to implement the abstract method in subclass.In other words,the subclass become the abstract class.
2.When use the abstract? When you are doing OOP,the method which is all exist between instance and instance and put them into the superclass.But there is no idea about what to the method should do,you can duplicated use the code by abstract and extends .For instance, there is a Animal class,and it have a sleep method,but it has different behaviors,maybe lie,hang or something like that,this time you can use abstract and extends to implement the relative sleep method by subclass.And when a class be signed the abstract keyword it can't instance.
3. Interface is important,it is good for communicate between blocks.When you set a interface,you create a class to implement it,you must run all abstract method and the method all use public keyword.You also can use it between two blocks,one class invoke the interface and the other implement the interface.But on this time the interface can not instance an object, so you must use its calling class instance an object,and let the reference instance assign to the interface's parameter.And it also can be extended,even it has more than one interface.And class can have many interfaces,when a class extends another class,the subclass can extends interfaces,just like subclass inherit method and variable from superclass.
Above these is only my thinking,maybe something right or not. And there are something i didn't refer,i'll do that later.I'm looking for your suggestion.And now,I also thank the people who give me hands,thank you so much,and have a good holiday,have a nice Middle-autumn day!
相关文章推荐
- Some thinking about scala concurrency compare to java
- Some thought about learning java
- some questions and tips about java
- some resource about 'Better, Faster, Lighter Java'
- Some understanding about the MVC
- Some Notes About JMM and JAVA String & Constants Pool
- some links about learning java
- some about wcg
- 03. Understanding More about Events and PostBack
- About the MariaDB Java Client
- Some Sites About .Net
- Some advice about life,hope u like it!
- Some notes about performSelector method
- Understanding Java 8 Streams API---reference
- Some useful java codes
- Some learning about AppDomain.DoCallBack
- Java 7: Understanding the Phaser
- the books about java
- some url about enlish
- some articles about linear-Z buffer and W-buffer