fork download
  1. import java.util.List;
  2.  
  3. class Ideone {
  4. public static int search(List<Integer> list, int x, int start, int end){
  5. while(end>=start){
  6. int middle = start/2+end/2;
  7. System.out.println(middle);
  8.  
  9. if(list.get(middle)== x ){
  10. return middle;
  11. }
  12. else if(list.get(middle) < x){
  13. start=middle+1;
  14. }
  15. else if(list.get(middle) > x) {
  16. end=middle-1;
  17. }
  18. }
  19. return -1;
  20. }
  21.  
  22. public static void main(String[] args){
  23. int[][] massiv = {{1,2,3},{2,3,4},{3,4,5}};
  24. int[] element = {2,3,4};
  25. System.out.println(search(massiv,element,0,2));
  26. }
  27. }
  28.  
  29.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:25: error: method search in class Ideone cannot be applied to given types;
    	System.out.println(search(massiv,element,0,2));
    	                   ^
  required: List<Integer>,int,int,int
  found: int[][],int[],int,int
  reason: actual argument int[][] cannot be converted to List<Integer> by method invocation conversion
1 error
stdout
Standard output is empty