fork 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[]array = {5,4,3,2,1};
  13. int largest = Integer.MIN_VALUE;
  14. int second = Integer.MIN_VALUE;
  15. int third = Integer.MIN_VALUE;
  16.  
  17. for(int i : array){
  18. if(i > largest){
  19. third = second;
  20. second = largest;
  21. largest = i;
  22. }else if(i > second){
  23. third = second;
  24. second = i;
  25. }else if(i > third){
  26. third = i;
  27. }
  28. }
  29. System.out.println(largest + " " + second + " " + third);
  30. }
  31. }
Success #stdin #stdout 0.1s 320320KB
stdin
Standard input is empty
stdout
5 4 3