public static Integer[] getTopThree(Integer[] values)
{
int max1 = Integer.MIN_VALUE;
int max2 = Integer.MIN_VALUE;
int max3 = Integer.MIN_VALUE; //assuming integer elements in the array
for (int i = 0; i < values.length; i++)
{
if (values[i] > max1)
{
max3 = max2; max2 = max1; max1 = values[i];
}
else if (values[i] > max2)
{
max3 = max2; max2 = values[i];
}
else if (values[i] > max3)
{
max3 = values[i];
}
}
Integer[] topThree = {max1, max2, max3};
return topThree;
}
It is returning this:
[Ljava.lang.Integer;@addbf1
[Ljava.lang.Integer;@addbf1
[Ljava.lang.Integer;@addbf1
What am I doing wrong?