While auditing an android source code, I found a string comparison bug which used == instead of equals(). However, the app is working well surprisingly!
After some testing, I found that replaceAll() method is hiding the bug.
String description = " ";
description = description.trim();
Result1.setText(description + " == " + "" + ": " + (description == ""));
prints "==:false" as I expected. However,
String description = " ";
description = description.trim().replaceAll("\\s+|\\r+|\\n+", " ");
Result1.setText(description + " == " + "" + ": " + (description == ""));
prints "==:true"! (Android 4.4.2, API 19)
I run the same code in my desktop (javac 1.6.0_45) and it prints "==:false" as I expected.
Is it a bug in Android or is it intended behavior?