0

how can I test a variable against everything in my array

title

24th Aug 2016, 5:11 PM
william
4 odpowiedzi
+ 2
public class Program { public static void main(String[] args) { int[] ary = {3,6,5,9}; for(int i : ary){ if(i == 5){ System.out.println("found"); break; } } } }
24th Aug 2016, 6:05 PM
Tiger
Tiger - avatar
+ 2
I just wanted a basic example of how one would compare a integer variable against a group of integers and tiger gave me what I needed
24th Aug 2016, 8:31 PM
william
+ 1
using loop
25th Aug 2016, 4:05 AM
Amit Yadav
Amit Yadav - avatar
0
Tiger your answer cant be 100% right since the person who posted this question didnt mention what type of array it is, it could be comparing an object against another collection of objects within the array and so forth. Finally the person who posted it please post a fully detailed question and provide an example for people to really help you. Thanks!
24th Aug 2016, 8:27 PM
Ousmane Diaw