Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java uses a String constant with the quotes

When i compare this constant string with MB inside with a variable with MB inside the result is false. The string constant looks like "MB" ([",M,B,"]=4 length) and my variable is "MB" ([M,B]=2 length). What's wrong here. Java cannot put the quotes inside the code into the string.

string constant

Var 2

public static final String gc_TelCodeFixed  = "FX";

if (!telcode.getId().equals(com.quoka.qis.db.constant.Constants.gc_TelCodeFixed)) 
    throw new TelcodeTypeMismatchException(telcode.getType()); 
like image 948
Hasan Tuncay Avatar asked Apr 09 '13 07:04

Hasan Tuncay


1 Answers

Invisible characters might cause this behavior.

How did the "MB" got there? did you type them or copy-paste from another program? Copy-paste operation might end up with invisible characters and text editors will not show them.

This can be easily reproduced by copying from PDF file with Linux Document Viewer.

Hope this helps, Yaron

like image 102
Yaron Reinharts Avatar answered Sep 23 '22 09:09

Yaron Reinharts