I was implementing a program to remove the duplicates from the 2 character array. I implemented these 2 solutions, Solution 1 worked fine, but Solution 2 given me UnSupportedOperationException. Why is that so? The error is at line al1.removeAll(al2);
public void getDiffernce(Character[] inp1, Character[] inp2){
// SOLUTION 1:
// **********************************************
List<Character> list1 = new ArrayList<Character>(Arrays.asList(inp1));
List<Character> list2 = new ArrayList<Character>(Arrays.asList(inp2));
list1.removeAll(list2);
System.out.println(list1);
System.out.println("***************************************");
// SOLUTION 2:
Character a[] = {'f', 'x', 'l', 'b', 'y'};
Character b[] = {'x', 'b','d'};
List<Character> al1 = new ArrayList<Character>();
List<Character> al2 = new ArrayList<Character>();
al1 = (Arrays.asList(a)); System.out.println(al1);
al2 = (Arrays.asList(b)); System.out.println(al2);
al1.removeAll(al2); // error is here
System.out.println(al1);
}