当前位置:网站首页>Interface learning
Interface learning
2022-07-03 06:46:00 【Xiao Xie Bu touch Yu】
interface
- General class : Only concrete implementation
- abstract class : Specific implementation and specification ( Abstract method ) There are !
- Interface : Only norms ! I can't write by myself , Professional constraints
- Interface is specification , It defines a set of rules , In the real world “ If you are … Must be able to …” Thought . If you are an angel , Must be able to fly . If you are a car , You have to be able to run . If you're a good person , You have to get rid of the bad guys ; If you are a bad person , You have to bully good people .
- The essence of an interface is a contract , Just like the law of our world . When it's done, everyone follows .
OO The essence of , It's the abstraction of objects , The best way to do this is through interfaces . Why do we talk about design Patterns are only for languages with abstract capabilities ( such as c++、java、c# etc. ), It's because of the design pattern , In fact, it's how to abstract reasonably . - The keyword of the declaration class is class, The key to declare the interface is interface
package com.oop.Demo08;
//interface Defined keywords , Interfaces need to have implementation classes
public interface UserService {
// Definition public static final
public static final int age = 99;
// All definitions in an interface are actually abstract public abstract
public abstract void add(String name);
void delete(String name);
void update(String name);
void query(String name);
// Interface function
/* 1. constraint 2. Define some methods Let different people realize 3. public abstract 4.public static final 5. Interface cannot be instantiated There is no constructor in the interface 6.implements Multiple interfaces can be implemented 7. You have to override the methods in the interface * */
}
==========================================================
package com.oop.Demo08;
public interface TimeService {
void run();
}
==========================================================
package com.oop.Demo08;
// abstract class :extents
// class Interface can be implemented implement Interface
// The class that implements the interface You need to rewrite the methods in the interface
// Multiple inheritance Using interfaces to implement multiple inheritance
public class UserServiceImpl implements UserService,TimeService{
@Override
public void add(String name) {
}
@Override
public void delete(String name) {
}
@Override
public void update(String name) {
}
@Override
public void query(String name) {
}
@Override
public void run() {
}
}
边栏推荐
- Read blog type data from mysql, Chinese garbled code - solved
- 10万奖金被瓜分,快来认识这位上榜者里的“乘风破浪的姐姐”
- Modify MySQL password
- 这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
- Local rviz call and display of remote rostopic
- HMS core helps baby bus show high-quality children's digital content to global developers
- scroll-view指定滚动元素的起始位置
- Docker advanced learning (container data volume, MySQL installation, dockerfile)
- Cannot get value with @value, null
- Summary of remote connection of MySQL
猜你喜欢

这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意

Golang operation redis: write and read hash type data

Selenium - by changing the window size, the width, height and length of different models will be different

IE browser flash back, automatically open edge browser

10万奖金被瓜分,快来认识这位上榜者里的“乘风破浪的姐姐”

scroll-view指定滚动元素的起始位置

Personally design a highly concurrent seckill system

论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》

The pressure of large institutions in the bear market has doubled. Will the giant whales such as gray scale, tether and micro strategy become 'giant thunder'?

YOLOV2学习与总结
随机推荐
UTC time, GMT time, CST time
Pdf files can only print out the first page
100000 bonus is divided up. Come and meet the "sister who braves the wind and waves" among the winners
New knowledge! The virtual machine network card causes your DNS resolution to slow down
The win7 computer can't start. Turn the CPU fan and stop it
Simple understanding of bubble sorting
2022-06-23 VGMP-OSPF-域间安全策略-NAT策略(更新中)
Pytest -- write and manage test cases
The mechanical hard disk is connected to the computer through USB and cannot be displayed
Example of joint use of ros+pytoch (semantic segmentation)
【开源项目推荐-ColugoMum】这群本科生基于国产深度学习框架PaddlePadddle开源了零售行业解决方案
Reinstalling the system displays "setup is applying system settings" stationary
(翻译)异步编程:Async/Await在ASP.NET中的介绍
Yolov2 learning and summary
第8章、MapReduce 生产经验
IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库
Code management tools
[classes and objects] explain classes and objects in simple terms
Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list