Here you can find the source of swap(T a, T b)
public static <T> void swap(T a, T b)
//package com.java2s; public class Main { public static <T> void swap(T a, T b) { T temp = a;//w w w. java 2s .co m a = b; b = temp; } }