Im trying to check which elements are the same in an array and then return the elements that are the same. Im thinking that i have to do a for loop inside of a for loop but im not sure. This is what i have so far:
for (int p = 0 ; p < temperatures.length ; p++) {
for (int j = 0 ; j < temperatures.length ; j++) {
if (temperatures[p] == temperatures[j]) {
System.out.println("matching" + j + p);
}
}
}
How i created the array:
for(int i = 0; i < temperatures.length; i++) {
System.out.println("Please enter the temperature in Celcius for day " + (i+1));
temperatures[i] = new Data(input.nextDouble());
}