I'm creating a program of letting people enter 10 integers and display them from the smallest to the largest. Here is my program:
import java.util.Scanner;
public class EnterTenNumbers { public static void main(String[] args){
System.out.println("Enter 10 numbers");
int small=0;
for(int i=0; i<10; i++){
Scanner in=new Scanner(System.in);
int[] i1=new int[10];
int num=in.nextInt();
i1[i]=num;
if(i1[i]<i1[i+1] || i1[i]==i1[i+1]){
System.out.println(i1);
}else if(i1[i]>i1[i+1]){
i1[i+1]=i1[i];
System.out.println(i1);
}
}
}
}
When I run my program, after the user input the numbers, such things like "[I@55f96302" appear.
And after the user entered 10 integers, Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10 at EnterTenNumbers.main(EnterTenNumbers.java:13) appears while it should display the numbers from smallest to largest.
What happened?