numbers[] is an array of int, so to compare an array with a variable
you have to compare one value at a time not with whole array, for
example: if (comp == numbers[2]) {}
Below is shown a piece of code where is demonstrated what I said:
int[] numbers={1,2,3,4,5};
int comp = 3;
int count = 0;
for(count = 0; count < numbers.length; count++){
if (comp == numbers[count]) {
System.out.println("comp value is the same as numbers
["+count+"] value");
}
}
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---