15th May 2017, 2:10 PM
Γιωργος Κωτσιοπουλος
Γιωργος Κωτσιοπουλος - avatar
6 Answers
+ 5
You never wrote the return type of the function check. Fix: static boolean check(.... You also never imported the package required for the ArrayUtils method. I believe it is java.lang.Object. ps: You need to do something with the boolean returned. Ex/ System.out.println(check(5));
15th May 2017, 2:36 PM
Rrestoring faith
Rrestoring faith - avatar
+ 5
Ah, I missed this error. Move int a; to the parameters of the function static boolean check(int a){ Then remove the "int a;" you wrote.
15th May 2017, 2:48 PM
Rrestoring faith
Rrestoring faith - avatar
+ 4
I think you may need to actually download something from apache commons in order to use arrayutil. according to stack over flow it's not part of the javas ordinary library. Consider making your own contains function This is called a linear search: private static boolean contains(int[] array, int key){ for(int i = array.length-1; i >=0; i--){ if(array[i] == key) return true; // found item }// end for return false; // did not find item } You can then remove that Object import I tolled you to add (sry). And re-write contains boolean. boolean contains = contains(opts, a); Also your if statements are redundant. You can just write: return contains; At the end of the check function, instead of those if/else statements.
15th May 2017, 3:24 PM
Rrestoring faith
Rrestoring faith - avatar
0
Thanks for the help but again it is not working
15th May 2017, 2:47 PM
Γιωργος Κωτσιοπουλος
Γιωργος Κωτσιοπουλος - avatar
0
Again the problem appears to be something with variable 'a'
15th May 2017, 2:50 PM
Γιωργος Κωτσιοπουλος
Γιωργος Κωτσιοπουλος - avatar
0
Ok thanks i will try that on pc
15th May 2017, 3:28 PM
Γιωργος Κωτσιοπουλος
Γιωργος Κωτσιοπουλος - avatar