-
Notifications
You must be signed in to change notification settings - Fork 9
Home
Why does 373 + 1 evaluate to 374 while "373" + "1" evaluate to "3731"? Underlying this question is the concept of a data type. In Java, every variable has a data type like int or String. Data types combine representation and functionality. An int can only represent integer numbers within a certain range and the plus operator computes the sum of the two values. A String, on the other hand, represents data as a sequence of characters and the plus operator appends the two strings.
Abstract data types (ADTs) are data types that do not specify a single representation of data and only include a specification for the functionality of the data type. In Java, abstract data types are often represented using interfaces like List, Set, or Map. Java provides implementations or specific representations of each interface through classes like ArrayList, TreeSet, or HashMap. All modern software is built with abstractions. Millions of programmers have written code using list types like Java's ArrayList. But have you ever wondered how lists are actually implemented in Java? Someone had to write the code to define the behavior for ArrayList. These lessons will explore how they designed their abstractions.
In software engineering, there's a distinction between being a client of a program versus being an implementer of a program. If you're working with a team of people on a software project, one person on your team might be responsible for writing the client while another person is responsible for writing the implementation. This distinction not only provides a blueprint for dividing a programming project into independent components, but it also allows for abstraction: the idea that we can change the implementation of the program without needing to rewrite all the client code too!
What would programming look like without abstraction?
Without abstraction, everyone who wrote a program using lists would have to go back and fix their code by copying-and-pasting updates every time the Java developers issue a fix for the list data type. There are millions of people using Java, and many of them use lists. Software development would grind to a halt if every update to Java required everyone who used a list to also make many changes.
Lessons are intended to be read in the following order:
- Dynamic Arrays
- Linked Nodes
- Asymptotic Analysis
- Iterative Sorts
- Binary Search
- Merge Sort
- Binary Search Trees
- Tries
- 2–3 Trees
- Left-Leaning Red-Black Trees
- Quicksort
- Counting Sorts
- Binary Heaps
- Hash Tables
- Affordance Analysis
- Graph Data Type
- Graph Traversals
- Shortest Paths Trees
- Problems and Solutions
- Topological Sorting
- Dynamic Programming
- Minimum Spanning Trees
- Disjoint Sets
Kevin Lin ©️ 2025 CC BY-NC-SA 4.0