Your error means, that You are comparing numbers[] array, numbers[] is
a reference to an object on a heap!
Here is solution - You cannot iterate array without a loop!!!
{
        int[] numbers = {1,2,3,4,5,6,8,12};
        int comp = Integer.parseInt(args[0]);
        for (int i = 0; i < numbers.length; i++) {
            if ( comp == numbers[i] )
                System.out.println("Equal: " + i);

        }
}

On Jul 23, 1:57 pm, nguyen thanh lam <[email protected]> wrote:
> Int numbers={1,2,3,4,5}
> int comp;
> if (comp == numbers[] )  // <==error here (" cannot compare int with
> int[] ")
>
> I want to compare a variable with many others. how i should do?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to