i want to swap the values of 'a' and 'b' and to return their values. I tried void type but it didnt swap the values. Now im trying this but eclipse saying that i didnt use 'return'.
public class swap {
public static int swap(int a, int b) {
int temp = a;
a = b;
b = temp;
int[] array = { a, b };
for (int i = 0; i < array.length; i++) {
return array[i];
}
}
public static void main(String[] args) {
System.out.println(swap(10, 5));
}
}