Java Base Adapter Mode

Source: Internet
Author: User

Li Wu:
Learn to think more, honouring teachers save Thanksgiving. Leaf See root Three return one, living water Qingyuan hidden in zero.
Meekness The Lord of Conscience, Haoyuedangkong the King of Freedom. Willing to give the most ascetic no regrets, sincere advice and the line and cherish.



Os:windows7 x64
Jdk:jdk-8u131-windows-x64
Ide:eclipse Oxygen Release (4.7.0)



Interface class

Package blog.jizuiku1;/** * Interface class *  * @author Jizuiku * @version V17.09.29 */public interface Userdao {void run (); void J UMP (); void drink ();}

Adapter class

Package blog.jizuiku1;/** * In the interface Class->__ adapter class __-> implementation Class  *  * There is no adapter class, then the implementation class will need all the methods in the interface class, even if not used to have the implementation * with the adapter class, Then the implementation class can have the choice of implementing the method in the interface class, the use of the implementation of *  * Adapter overrides all functions in the interface, the implementation class inherits the adapter class *  * @author Jizuiku * @version V17.09.29 */public Abstract class Useradapter implements Userdao {@Overridepublic void Run () {//TODO auto-generated method stub} @Overridepub LIC void jump () {//Todo auto-generated method stub} @Overridepublic void Drink () {//Todo auto-generated method stub}}

Adapter-based Implementation classes

Package blog.jizuiku1;/** * Implementation class *  * @author Jizuiku * @version V17.09.29 */public class Userdaoimpl extends Useradapte R {@Overridepublic void run () {//TODO auto-generated method StubSystem.out.println ("Running");}}

Test class

Package blog.jizuiku1;/** * Test class *  * @author Jizuiku * @version V17.09.29 */public class Userdaoimpldemo {public static void Main (string[] args) {Userdao u = new Userdaoimpl (); U.run ();//There is a question: Although the code in the implementation class Userdaoimpl is indeed streamlined//But the U.jump () function is not even Implementation, can still be smart tips//This is conducive to development?}}

Results

Java is good, worth learning.
The design pattern contains extremely high intelligence, which is helpful to project development.
Learning resources: Itcast and Itheima Video library. If you have public resources, can share to me, with your resources to learn also can.
Blog post is to watch the video, into thinking written. It's good that the teacher speaks well. Blog bad, is to give the most bitter not serious.

Java Base Adapter Mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.