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

Java :Checking for Not equal to

Former Member
0 Likes
1,424

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

or you can use this...this will also work

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

(str4.equals("00000000")) )

result.addValue("");

}

Note: I applied De Morgans law to what others said....[ !A && !B = !(A || B) ]

i am using something i learned during my bachelor's degree....