/Java-Collections-Practice-Problems

A repository containing a collection of Java practice problems focused on the usage of the Collections framework in Java 8. These problems cover a variety of scenarios and operations to help you strengthen your skills in working with Java collections.

Java 8 Collections Library Practice Problems

This repository contains a collection of practice problems to help you practice using the Collections library in Java 8.

Problems

ArrayList

  1. Write a program to sort an ArrayList of Strings alphabetically.
  2. Write a program to find the maximum element from an ArrayList of Integers.
  3. Write a program to remove all duplicate elements from an ArrayList.
  4. Create a LinkedList and perform various operations like add, remove, and iterate over it.
  5. Write a program to find the intersection of two ArrayLists.
  6. Write a program to shuffle the elements of an ArrayList.
  7. Write a program to find the second-largest element in an ArrayList of Integers.
  8. Write a program to find the frequency of each element in an ArrayList.
  9. Write a program to find the kth smallest element in an ArrayList.
  10. Write a program to merge two ArrayLists into a single ArrayList.
  11. Write a program to find the intersection of multiple Sets.
  12. Write a program to check if two LinkedLists are equal.
  13. Write a program to check if a HashSet is a subset of another HashSet.

HashSet

  1. Create a HashSet and add some elements to it. Then, print the elements of the HashSet.
  2. Write a program to check if a particular element exists in a HashSet.
  3. Create a HashMap to store the mappings of country names to their capitals.
  4. Write a program to find the common elements between two ArrayLists.
  5. Create a TreeMap to store the mappings of words to their frequencies in a given text.
  6. Write a program to check if a HashSet is a subset of another HashSet.

PriorityQueue

  1. Implement a PriorityQueue and add elements to it. Then, print the elements in sorted order.
  2. Implement a priority queue using the PriorityQueue class.
  3. Implement a priority queue using a custom comparator.
  4. Implement a PriorityQueue using a custom comparator.
  5. Implement a Queue using the PriorityQueue class with a custom comparator.
  6. Implement a Stack using the PriorityQueue class with a custom comparator.

Stack

  1. Implement a Stack using the Stack class in Java.
  2. Implement a Stack using the LinkedList class.
  3. Implement a Stack using the ArrayDeque class.
  4. Implement a Stack using the PriorityQueue class with a custom comparator.

TreeMap

  1. Create a TreeMap and add elements to it. Then, print the elements in sorted order of keys.
  2. Create a TreeMap to store the mappings of book titles to their authors.
  3. Create a TreeMap to store the mappings of words to their frequencies in a given text.
  4. Create a TreeMap to store the mappings of student IDs to their details.

LinkedList

  1. Create a LinkedList and perform various operations like add, remove, and iterate over it.
  2. Implement a Queue using the LinkedList class.
  3. Implement a Stack using the LinkedList class.
  4. Write a program to check if two LinkedLists are equal.

Queue

  1. Implement a Queue using the LinkedList class.
  2. Implement a priority queue using a custom comparator.
  3. Implement a Queue using the PriorityQueue class.
  4. Implement a Queue using the ArrayDeque class.
  5. Implement a Queue using the PriorityQueue class with a custom comparator.

TreeSet

  1. Create a TreeSet and add elements to it. Then, print the elements in sorted order.
  2. Create a TreeSet of custom objects and implement the Comparable interface for sorting.

HashMap

  1. Create a HashMap to store the mappings of country names to their capitals.
  2. Create a HashMap to store the mappings of employee IDs to their names.
  3. Create a HashMap to store the mappings of city names to their populations.
  4. Create a HashMap to store the mappings of product names to their prices.
  5. Create a HashMap to store the mappings of employee IDs to their departments.