课程: Java Object-Oriented Programming
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Writing flexible code with compile-time polymorphism - Java教程
课程: Java Object-Oriented Programming
Writing flexible code with compile-time polymorphism
- [Instructor] Java also supports compile-time polymorphism to make your code faster and cleaner. With compile-time polymorphism we can have more than one method with the same name, let's take a look. With the ConditionArrayList, we can create a new list with a predicate. In this case, the condition is if the number isDivisibleByThree. We can also create a ConditionArrayList by providing a series of numbers, in addition to the predicate. Only those that satisfy the condition will be added to the list. We're able to use the constructor in this way, because the second input to our constructor is a variable argument. You can input zero numbers, one number, or as many as you want. However, they do have to be in a series or array format. If you want to add another list or collection to the ConditionArrayList, it's currently not possible. In fact, when we try we get an error saying it cannot resolve the constructor, and…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
(已锁定)
What is polymorphism?1 分钟 22 秒
-
(已锁定)
Writing reusable algorithms with runtime polymorphism4 分钟 47 秒
-
(已锁定)
Exploring different forms in a single object4 分钟 6 秒
-
(已锁定)
Accessing specific object forms with instanceof4 分钟 23 秒
-
(已锁定)
Writing flexible code with compile-time polymorphism4 分钟 38 秒
-
(已锁定)
Exploring how built-in Java classes use polymorphism3 分钟 39 秒
-
(已锁定)
Challenge: Reduce complexity with polymorphism48 秒
-
(已锁定)
Solution: Reduce complexity with polymorphism6 分钟 57 秒
-
(已锁定)
-
-