0

I need to compare int[] array with integer values. This code am having

int c1[], c2[], c3[];
int count1=0, count2=1, count3=0;
c1 = new int[] { count1 };
c2 = new int[] { count2 };
c3 = new int[] { count3 };

Now i need to compare this int[] array with int, that is any array equals 0 then code don't need to execute if not equals then code execute. How to compare ?? help me thanks in advance ? this if condition i tried but it wont execute exactly.

if(c1.equals(0))
{
 // skip
}
else 
{
 // execute code
}

this above code didn't work.

1

3 Answers 3

3

Try following:

for(int i=0;i<cl.length;i++){
   if(c1[i]==0)
    {
     // skip
    }
   else 
   {
 // execute code
   }
}
Sign up to request clarification or add additional context in comments.

Comments

2

Perhaps you are looking for :

if(c1[0] == 0)
{
 // skip
}
else 
{
 // execute code
}

Though it's unclear why you need c1 to be an array if it only holds a single integer.

Comments

1

Use c1[0],c1[1] .... and (iterate through loop)

like-

if(c1[0]==0)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.