基本上我有一个位置的ArrayList:
ArrayList<WorldLocation> locations = new ArrayList<WorldLocation>();
Run Code Online (Sandbox Code Playgroud)
下面我称之为以下方法:
.getMap();
Run Code Online (Sandbox Code Playgroud)
getMap()方法中的参数是:
getMap(WorldLocation... locations)
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我不确定如何将整个列表locations传入该方法.
我试过了
.getMap(locations.toArray())
Run Code Online (Sandbox Code Playgroud)
但getMap不接受,因为它不接受Objects [].
现在,如果我使用
.getMap(locations.get(0));
Run Code Online (Sandbox Code Playgroud)
它会完美地工作......但我需要以某种方式传递所有位置...我当然可以继续添加locations.get(1), locations.get(2)等等但是阵列的大小各不相同.我只是不习惯整个概念ArrayList
最简单的方法是什么?我觉得我现在不想直接思考.