Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
amtkmr1990
Contributor II
Contributor II

difference between row2.state.equals('Arizona') vs 'Arizona'.equals(row2.state)

Hello Team, 

Could help me explain the difference between 

row2.state.equals('Arizona') vs 'Arizona'.equals(row2.state)

in expresssion under tjoin inner join tab.

Labels (2)
1 Solution

Accepted Solutions
TRF
Creator III
Creator III

"Arizona".equals(row2.state) will never finish by a null pointer exception but row2.state.equals("Arizona") will fail if row2.state is null.

View solution in original post

4 Replies
TRF
Creator III
Creator III

"Arizona".equals(row2.state) will never finish by a null pointer exception but row2.state.equals("Arizona") will fail if row2.state is null.

amtkmr1990
Contributor II
Contributor II
Author

thanks TRF. 

rmartin2
Creator II
Creator II

As TRF said, you should NEVER use the first one.

 

The second create a static String object, which prevent any exception, so you can do many operations like : !"".equals(row1.data)

The first syntax is a bad syntax and should be banned from all Java code you can ever find 0683p000009MACn.png

 

You can use that trick in many situations if you're not sure of the nullability of your String.

 

Example : row1.data+""      will never be null, even if "data" is an Integer 0683p000009MA9p.png

amtkmr1990
Contributor II
Contributor II
Author

Actually i was using this Arizona'.equals(row2.state) in tmap to only select rows with Arizona.

 

TMSSQLinput     -              tmap          -    MSSQLoupt

tmssqlinput (Lookup)  - above tmap