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[] n = {0, 1, 3, 5, 9, 11, 15};
  13. int[] m = {5, 2, 3, 10, 9, 12};
  14. System.out.println(isSorted(n));
  15. System.out.println(isSorted(m));
  16. }
  17. public static boolean isSorted(int[] n){
  18. for(int i = 0; i < n.length - 1; i++){
  19. if(n[i + 1] < n[i]){
  20. return false;
  21. }
  22. }
  23. return true;
  24. }
  25.  
  26. }
Success #stdin #stdout 0.06s 2841600KB
stdin
Standard input is empty
stdout
true
false