You have to use or read about associative arrays, or maps,..etc. Storing the the number of occurrences of the repeated elements in array, and holding another array for the repeated elements themselves, don't make much sense.
Your problem in your code is in the inner loop
for (int j = i + 1; j < x.length; j++) {
if (x[i] == x[j]) {
y[i] = x[i];
times[i]++;
}
}