课程: Java Object-Oriented Programming
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Exploring how built-in Java classes use polymorphism - Java教程
课程: Java Object-Oriented Programming
Exploring how built-in Java classes use polymorphism
- [Instructor] The Java programming language uses both runtime and compile-time polymorphism under the hood, let's take a look at the ArrayList class. The ArrayList class has two methods with the name addAll, but they have different sets of parameters. The first addAll takes in one parameter, a collection. In the implementation, it adds all the elements from that collection to the end of the ArrayList. Scrolling down, we can see that the second addAll takes in two parameters, the index and the collection. We want to add all the elements to the list, but the index allows us to specify a specific location to add them. We could add the items at the beginning of the list, the end of the list, or somewhere in the middle, and we'd specify where, using that index. The first implementation assumes we want to add the collection to the end, but the second implementation gives us a little more control over where we add the items, this…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
(已锁定)
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 秒
-
(已锁定)
-
-