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. static int SeqSearch(int[] list, int key) {
  11. for (int i = 0; i < list.length; i++)
  12. if (key == list[i])
  13. return i;
  14. return -1;
  15. }
  16. public static void main (String[] args) throws java.lang.Exception
  17. {
  18.  
  19. int[] list = {10,5,2,17,7,6,1,20,3,9,4,12,8};
  20.  
  21. int z= SeqSearch(list , 9);
  22. System.out.print(z);
  23. ;
  24.  
  25. }
  26. }
Success #stdin #stdout 0.09s 52596KB
stdin
Standard input is empty
stdout
9