课程: Java Object-Oriented Programming
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Using interfaces in Java to provide conformity - Java教程
课程: Java Object-Oriented Programming
Using interfaces in Java to provide conformity
- [Instructor] Another way we can add abstraction to our Java programs is through interfaces. An interface is a set of method signatures for to-be-implemented functionality. It's kind of like a specification for a set of behavior without the implementation. So like an abstract class, an interface cannot be instantiated. Let's take a look at an example. Here we have an event interface. Any class that wants to use the event interface must implement the getTimeStamp and process methods and return the appropriate type. To use an interface, another class implements it, using the implements keyword. Let's create a class that uses this interface. We'll call it PasswordChangeEvent. This event is created when a user changes their password. To have it use the event interface, we'll use the keyword implements. Of course, we aren't done yet. In order for this class to properly implement the event interface, it must have…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
-
(已锁定)
What is abstraction?1 分钟 47 秒
-
(已锁定)
Using abstract classes in Java to reduce code complexity5 分钟 59 秒
-
(已锁定)
Using interfaces in Java to provide conformity5 分钟 1 秒
-
(已锁定)
Discovering abstraction in Java source code4 分钟 55 秒
-
(已锁定)
Challenge: Leverage abstraction to write simpler applications1 分钟 19 秒
-
(已锁定)
Solution: Leverage abstraction to write simpler applications2 分钟 58 秒
-
(已锁定)
-