I'm quite new to Java and recently I wanted to practice more. So I stumbled in this. I wanted to print out all the values in the array using Array.sort, but all I get is:1,2,3,4,5,6 instead of;22,51,67,12,98,34.
Here is the code:
public static void main(String[] args) {
int[] array;
array =new int[6];
array[0]=22;
array[1]=51;
array[2]=67;
array[3]=12;
array[4]=98;
array[5]=34;
Arrays.sort(array);
int i;
for (i=0; i < array.length; i++){
array[i]= i+1;
System.out.println("num is"+array[i]);
}