课程: Java: Advanced Concepts for High-Performance Development
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
The Liskov substitution principle in Java - Java教程
课程: Java: Advanced Concepts for High-Performance Development
The Liskov substitution principle in Java
- [Instructor] The list of substitution principle helps you write more flexible and maintainable code. The name makes it sound like it's going to be something really complicated, but it's not as bad as it sounds. It just means that a subtype should behave in the same way as its supertype. So let's look at an example. For this chapter, I have some code that's a simple representation of an online clothing store where people can order different items of clothing. So first, I have an abstract class called ClothingItem and this class has two abstracts methods in it, getPrice and getName. Then there are two classes that extends this abstract class, so one of them is the ShirtItem class and in this class the getPrice method returns 10 and the getName method returns the word Shirts. Then there's one called JacketItem and in this class the getPrice method returns 25 and the getName method returns the word Jacket. Finally…
内容
-
-
-
-
Introduction to generics in Java4 分钟 15 秒
-
(已锁定)
Generic methods in Java3 分钟 24 秒
-
(已锁定)
Bounded generics in Java1 分钟 43 秒
-
(已锁定)
The Liskov substitution principle in Java4 分钟 28 秒
-
(已锁定)
Using wildcards in generic programming2 分钟 45 秒
-
(已锁定)
Challenge: Using generics2 分钟 17 秒
-
(已锁定)
Solution: Using generics1 分钟 41 秒
-
-
-
-
-
-
-