xxxxxxxxxx
import java.util.*;
Set<Integer> set = new HashSet<>();
// Add elements to the set
set.add(5);
set.add(10);
set.add(15);
set.add(20);
List<Integer> list = new ArrayList<>(set); // Convert set to list
int k = 2; // Index of the element we want to access
int element = list.get(k);
System.out.println("Element at index " + k + ": " + element);