Java Swap two elements with swap()

The Collections method swap() is very useful to swap two values in a programming code. For example, the prices of two different dates can be swapped. This method comes into existence with JDK 1.4. Following is the method signature of swap() method static void swap(List list1, int index1, int index2): List list1 elements at index …

Java Swap two elements with swap() Read More »