I would like to know why and how to fix this array method outputs the memory representation of temp.
public class StringMethodsExersice{
public static int[] shiftMax(int[] num){
int temp[] = new int[num.length];
int firstEl = num[0];
int lastEl = num[num.length-1];
for(int i=1;i<num.length-1;i++){
if(num[i] > num[i+1]){
temp[i] = num[i];
}
temp[i] = num[i];
}
temp[0] = firstEl;
temp[num.length-1]= lastEl;
return temp;
}
public static void main (String []args){
int[] myArray = new int [5];
myArray [0] = 2;
myArray [1] = 5;
myArray [2] = 6;
myArray [3] = 14;
myArray [4] = 25;
System.out.println(shiftMax(myArray));
}
}