From Array to ArrayList

Lesson X - 25 September 2019

How was the Preject?

Congratulations! OOP done

Three random questions...

  • what is an abstract class?
  • what is an interface?
  • what is method overriding?

Data Structures

What are they?

A way to store and organize data so that it can be used efficiently

But I have Arrays!

Java Collections Framework

(doc)

ArrayList

(doc)

Why ArrayList is better than Array?

supports dynamic arrays that can grow as needed!

Package

a namespace that organizes a set of related classes and interfaces

Let's code!

Homework

  • Write a program to find the second smallest element in an array of integers. Write a porgram to find the second smallest element in an array list of integers.
  • Try to add new functionalities to the Country class, let's make sure that for every country we can track the bordered countries. Would a ArrayList be the best approach? If not, why not?

Credits

  • Collections (simple): https://opensourceforu.com
  • Collections (complex): https://medium.com/omarelgabrys-blog
  • Photos: Unsplash