Not able to create List of String object in java12

279 Views Asked by At
List<Object> al = Arrays.asList("ABC", "XYZ");

This code works fine in Java11 but when I try this in Java12, it gives an error.

Any hint of what I am missing?

Thanks for the help.

minimal code as asked:

import java.util.Arrays;
import java.util.List;

public class TestFile {
 public static void main(String str[]){
    List<Object> al = Arrays.asList("ABC", "XYZ");
}

Erro log: Error:(58, 42) java: incompatible types:java.util.List<java.lang.String> cannot be converted to java.util.List<java.lang.Object>

Java version 12,System windows 10 and IDE intelij

0

There are 0 best solutions below