What the code does is, basically, asks for number of elements that you want to sort,the elements and prints them sorted. Or at least it should. When I run it it would do that:

What should I do? I'm using JDK 7 and IntelliJ IDEA 15.
And yes, I did google it and I couldn't find anything. And no , I don't want the code, I want opinions.
import java.text.MessageFormat;
import java.util.Scanner;
public class bb {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.print("Enter number of elements:");
int numberOfElements = scan.nextInt();
System.out.print(MessageFormat.format("Enter {0} {1} ",numberOfElements,"numbers: "));
int [] elements = new int[numberOfElements];
for (int i = 0; i < elements.length; i++) {
elements[i]=scan.nextInt();
java.util.Arrays.sort(elements);
}
System.out.println(java.util.Arrays.toString(elements));
}
}
elementsalready has 0 set as a default value for all the array values (with the exception of the one you are setting right now or have set). This means that it's possible to overwrite a previously read value (this happens to you).