fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int[] numbers = { 5, 8, 14, 1, 5678 };
  13. int tempVar;
  14. for (int i = 0; i < numbers.length-1; i++)
  15. {
  16. for(int j = 0; j < numbers.length-i-1; j++)
  17. {
  18. if(numbers[j] > numbers[j + 1])
  19. {
  20. tempVar = numbers [j + 1];
  21. numbers [j + 1]= numbers [j];
  22. numbers [j] = tempVar;
  23. }
  24. }
  25. }
  26. for (int i = 0; i < numbers.length; i++)
  27. {
  28. System.out.println(numbers[i]);
  29. }
  30. }
  31. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
1
5
8
14
5678