E m*_*mad 2 java collections swap arraylist
我搜索了很多网站,但我发现的唯一的东西就是这个链接
我有一个BSNode类.我有一个ArrayList<BSNode> data,现在我想交换两个变量,但我面临这个错误:
The type of the expression must be an array type but it resolved to ArrayList<BSNode>
Run Code Online (Sandbox Code Playgroud)
有什么方法可以换掉这两个吗?当我想比较两个变量时,我只是在BSNode类中实现了可比性,并且我重写了一个方法.但我应该怎么做才能在数组列表中交换它们?
我有这个方法:
public static void permutation (ArrayList<BSNode> data, int k, int n)
Run Code Online (Sandbox Code Playgroud)
我想这样做:
for (int i = k; i < n; i++) {
Collections.swap(data, data[k], data[i]);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7982 次 |
| 最近记录: |