Exercises
You may not have noticed directly, but we’ve been longing for this! We can finally add collections and generics to the applications of our apps. Life will get easier. Let’s look at some exercises:
- Our park has an assortment of dinosaurs and their related data. Implement a
List
interface that stores a custom dinosaur class. - We need to ensure that the most dangerous dinosaurs are taken care of first. Write a
PriorityQueue
class that sorts dinosaurs based on a customComparator
interface, such as their danger level. - Generics can make our code more reusable. Create a class called
Crate
with a generic for the thing you’d like to store in there. This could be food or drinks for the restaurant, but also dinosaurs if we need to relocate them. - Create three instances of your
Crate
class with different classes in your program – for example,Dinosaur
,Jeep
, andDinosaurFood
. - Hashing is essential for efficient data handling. Override...