Not able to create List of String object in java12

ぐ巨炮叔叔 提交于 2020-02-22 08:32:31

问题


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

来源:https://stackoverflow.com/questions/60240353/not-able-to-create-list-of-string-object-in-java12

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!