Objectives: In this lab, the following topic will be covered: 1. Generics Task Implement an ordered list capable of hold
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Objectives: In this lab, the following topic will be covered: 1. Generics Task Implement an ordered list capable of hold
Objectives: In this lab, the following topic will be covered: 1. Generics Task Implement an ordered list capable of holding objects of an arbitrary type, T, by defining a Ordered List class that implements the list with an ArrayList. An ordered list is a type of list where a new item will be added in its correct location to keep the list ordered. Your class should support the following methods: .add(item) - adds an item in its location (do not use the sort method). .toString()-returns the list For example, if list is an ordered list defined to take Integer objects list.add(30); list.add(10); list.add(20); System.out.println(list); // prints [10, 20, 30]
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!