gpt4 book ai didi

java - java中的数组和链表

转载 作者:行者123 更新时间:2023-12-02 05:30:34 26 4
gpt4 key购买 nike

你能给我解释一下这段代码吗?arrays.aslist(job) 是什么意思?

String jobs[] ={"senior","programmeur","project manager"};
LinkedList<String> links = new LinkedList<String>(Arrays.asList(jobs));

最佳答案

来自文档:

Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.) This method acts as bridge between array-based and collection-based APIs, in combination with Collection.toArray(). The returned list is serializable and implements RandomAccess.

用于创建快速列表,例如:

List<String> stooges = Arrays.asList("Larry", "Moe", "Curly");

参见here

关于java - java中的数组和链表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25591019/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com