Creating a Swap Function

# Introduction In Java, swapping primitive data types is easy and can be done with simple variable assignment. However, swapping non-primitive data types, like objects, can be complex. Fortunately, the `java.util.Collections` class includes a `swap()` method that makes it easy to swap elements in a list of primitive and non-primitive data types. In this lab, you will learn how to create a swap function using the `Collections.swap()` method.

|60 : 00

Click the virtual machine below to start practicing