Create ArrayList from array

后端 未结 30 1804
遇见更好的自我
遇见更好的自我 2020-11-21 22:29

I have an array that is initialized like:

Element[] array = {new Element(1), new Element(2), new Element(3)};

I would like to convert this

30条回答
  •  感情败类
    2020-11-21 22:49

    In Java 9 you can use:

    List list = List.of("Hello", "World", "from", "Java");
    List list = List.of(1, 2, 3, 4, 5);
    

提交回复
热议问题