ArrayList<class> collection.swap method
arraylist, collections, java, swap
Solution
use `Collections.swap(data, k,i);` instead of `Collections.swap(data, data[k], data[i]);`
Problem
I have search many many sites but the only thing which I found was This link I have a BSNode class. I have make an `ArrayList<BSNode> data` and now I want to swap two variables but i face this error : ``` The type of the expression must be an array type but it resolved to ArrayList<BSNode> ``` is there any way I can swap this two? when I want to just compare two variables, I just implement comparable in BSNode class and I override one method. but what should I do to SWAP them in array list? i have this method : ``` public static void permutation (ArrayList<BSNode> data, int k, int n) ``` and I want to do this: ``` for (int i = k; i < n; i++) { Collections.swap(data, data[k], data[i]); } ```