Array转List

    技术2026-05-09  2

    1. Arrays.asList(array);

    public static void main(String[] args) { String[] words = { "ace", "boom", "crew", "dog", "eon" }; List<String> wordList = Arrays.asList(words); for (String e : wordList) { System.out.println(e); } } 

     

    2. Collections.addAll(list, array);

    public static void main(String[] args) { String[] words = { "ace", "boom", "crew", "dog", "eon" }; List<String> wordList = Arrays.asList(words); } 

    最新回复(0)