课程: Java: Advanced Concepts for High-Performance Development
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Using wildcards in generic programming - Java教程
课程: Java: Advanced Concepts for High-Performance Development
Using wildcards in generic programming
- [Instructor] In the previous video, we saw how the substitution principle can help us write clean code, but it's also important to know when the principle doesn't apply. So, in this ClothingSite class, I've got my main method and inside that I'm creating two objects, a ShirtItem and a JacketItem. And ShirtItem and JacketItem both extends the ClothingItem class. And then I'm creating an array list containing ClothingItems and I'm adding the shirtItem and the jacketItem to that list. And then finally, I'm calling the checkoutAllItems method and I'm passing in my list of clothingItems. And in the checkoutAllItems method I'm iterating over that list. And for each one, I'm checking out the item. But let's say, I want to create a list that just contains ShirtItems and not JacketItems. So, I'm going to change this JacketItem to another ShirtItem, and I'll call it shirtItem2. And on the right hand side…
内容
-
-
-
-
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 秒
-
-
-
-
-
-
-