From the course: Java Object-Oriented Programming
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Discovering abstraction in Java source code - Java Tutorial
From the course: Java Object-Oriented Programming
Discovering abstraction in Java source code
- [Instructor] To find some more examples of abstraction, We can look at the Java source code. Java uses abstract classes and interfaces to reduce complexity. Let's jump in. We've taken a look at the ArrayList class a few times now. In its definition, we see it extends AbstractList, which is an abstract class. It also implements a few interfaces. In Java, a class can only extend one other class, but it can implement several interfaces. Let's take a look at the AbstractList class. This extends Abstract Collection because a list is a specific type of collection. Going into Abstract Collection, we see a few abstract methods as well as a few methods that are already implemented. For example, is empty takes whatever the size returns and checks if it's zero. This is a base algorithm that is the same for all collections. Many of the implemented methods use the abstract methods in order to calculate various things such as…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
What is abstraction?1m 47s
-
(Locked)
Using abstract classes in Java to reduce code complexity5m 59s
-
(Locked)
Using interfaces in Java to provide conformity5m 1s
-
(Locked)
Discovering abstraction in Java source code4m 55s
-
(Locked)
Challenge: Leverage abstraction to write simpler applications1m 19s
-
(Locked)
Solution: Leverage abstraction to write simpler applications2m 58s
-
(Locked)
-