fork(4) 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. List<Integer> sequence = new ArrayList<Integer>();
  13. sequence.add(4);
  14. sequence.add(5);
  15. sequence.add(7);
  16. sequence.add(8);
  17. int match = 0;
  18. int first = sequence.get(0); // sets the first value in seq. to var
  19. int size = sequence.size(); // sets the seq size to var
  20. for (int i = 0; i < size; i++)
  21. {
  22. if ((first + i) != sequence.get(i)) {
  23. match = (first + i);
  24. break;
  25. }
  26. }
  27. System.out.println(match + " is not in the sequence.");
  28.  
  29. }
  30. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
6 is not in the sequence.