This program is running fine but when I try to run the code with any of these commented-out statements it throws an "UnsupportedOperationException" error and I can't figure out why. I don't want to add elements to the list Individually.
/* 
    List<String> strings =Arrays.asList("Namste", "India", "..!"); 
    --> java.base/java.util.AbstractList.add      
*/
/*     
List<String> strings =List.of("Namste", "India", "..!");
    --> java.util.ImmutableCollections$AbstractImmutableCollection.add      
*/
List<String> strings =new ArrayList<>();                
strings.add("Namaste");
strings.add("India");
strings.add("..!");
        
System.out.printf("Before : ");
for (String string : strings) 
     System.out.printf("%s ",string);
        
Methods.addAll(strings, "G","K");        
System.out.printf("\nAfter : ");
for (String string : strings) 
     System.out.printf("%s ",string);
Methods.addAll is defined like this:
public static <T> void addAll(List<T> list, T... arr) {
        for (T elt : arr) list.add(elt);
}
 
     
     
    