Forum Discussion

vwanaskar's avatar
vwanaskar
Occasional Contributor
11 years ago

!= and == operator not working for if read the value from .csv file file and compare using java

Hi all,



here i am trying to compare cell value(it could be alphabate,digit or combination of both) of  of two differnt .csv file using java.so I am reading that value from .CSV file and compare but it showing wrong for == and < ,> operator.it showing behaviour as follow.



  * For  !=   and ==  it showing true for same and different value .



  * if i used <and > operator in place of == operator it working ok for only alphabate or digit but not for combination of both. that means it showing same even value are differnt for combination of alphabate and digit.

 

if tried same script without reading value from csv file then it working ok.



can any one help me to solve this problem.











1 Reply

  • Philip_Baird's avatar
    Philip_Baird
    Community Expert
    Hi Vijay, I am assuming by "java" you mean JScript.



    If so, be aware that JScript has two equality and inequality operators



    == and ===

    != and !==



    == and != employ type coersion, i.e. if the operands are of a different type, the JScript runtime will coerce one of the operands so it can perform the operation, e.g.



    Log.Message( 11 == "11" ); // Logs true



    This can lead to unexpected results, whereas === and !== do NOT employ type coersion and will always evaluate correctly e.g.



    Log.Message( 11 === "11" ); // Logs false



    I mention this as you appear to be dealing with alphanumerics from a csv file where this may come into play



    Regards,

    Phil Baird