I have added Selenium and Java program below. It is based on List and and HashMap in Java. You can calculate the output and provide the comments below. Click on the button “Click for solution” to view the solution.
import org.testng.annotations.Test;
import java.util.*;
public class SampleProgram8 {
@Test
public void testMySkills() {
System.out.println("Function returns Object with size "+findSize());
}
public int findSize() {
List<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
list.add(2);
list.add(5);
list.add(5);
int size = list.size();
HashSet<Integer> set = new HashSet();
for(int i=0;i<size;i++) {
set.add(list.get(i));
}
return set.size();
}
}