How can I convert a pair array to a simple array as show below?
class Pair {
int x;
int y;
public Pair(int a, int b){
x = a;
y = b;
}
}
// you are given an array of this pair class
Pair[] p = {new Pair(5, 24), new Pair(39, 60), new Pair(15, 28),
new Pair(27, 40), new Pair(50, 90)};
// I want to covert this into a simple array like
int[] arr = {5, 24, 39, 60, 15, 28, 27, 40, 50, 90};
As you can see I want to convert p into arr with each pair representing two numbers in the simple array.