In List<MyObject> list = new ArrayList<>() i want to swap position of two (always) objects that have the same value in field name.
public class SiteDTO {
private Long id;
private String name;
// getters setters constructors
}
i know that best way to do that is using Collections.swap(list, 1, 2); where 1 and 2 are positions of objects to swap.
But how to find these indexes?