1.

Write A Generic Method To Exchange The Positions Of Two Different Elements In An Array.

Answer»

public final class ALGORITHM
{
public static <T> void swap(T[] a, INT i, int j)
{
T TEMP = a[i];
a[i] = a[j];
a[j] = temp;
}
}

 

public final class Algorithm
{
public static <T> void swap(T[] a, int i, int j)
{
T temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}

 



Discussion

No Comment Found