public class Methods3 { public static void main (String[] args) { int[] x = {1, 4, 5, -1}; search1(x,-1); System.out.println(search2(x,-1)); } // linear search for target in data x // return early if found: public static void search1(int[] x, int target) { for (int i = 0; i < x.length; i++) if (x[i] == target) { System.out.println("Success!"); return; } } // linear search for target in data x // return true if found, else false: public static boolean search2(int[] x, int target) { for (int i = 0; i < x.length; i++) if (x[i] == target) return true; return false; } }