cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Java :Checking for Not equal to

Former Member
0 Likes
1,429

Hi Group,

In Java How to Check the Condition for not equals to

When I am using the following code I am not getting expected result:



String str1 = new String();
String str2 = new String();
String str3 = new String();
String str4 = new String();

for (int i =0; i<a.length; i++)
{
str1=a<i>.substring(0,6);
str2=a<i>.substring(7,14); 
str3=a<i>.substring(18,23); 
str4=a<i>.substring(24,31); 
if ( (!str1.equals("000000")) || (!str2.equals("00000000")) || (!str3.equals("000000")) ||
    (!str4.equals("00000000")))
 
result.addValue("");

}

View Entire Topic
Former Member
0 Likes

Hi,

if your req is that any of str1 to str4 is not equal to 0, then add in resultlist, then the below code may help you:

if (!( (str1.equals("000000")) && (str2.equals("00000000")) && (str3.equals("000000")) && (str4.equals("00000000"))))

result.addValue("");

Thanks,

Rajeev Gupta