My problem is hidden in next code:
public class saturo {
public String primer, d;
public void start() {
primer = "545640";
//d = "0";
d = String.valueOf(primer.charAt(((primer.length())-1)));
if(d == "0"){
System.out.println("This is equal: d == " + d);
}else{
System.out.println("This is not equal: d == " + d);
}
}
public static void main(String args[]) {
new saturo().start();
}
}
So as you see, the problem is that if i declare String d as "0" than the program will execute it as d is equal to "0" and return true
;
But if i get character "0" from a String, convert it to String, and check if this equals to "0" then i have got a false
.
I have checked if there is something wrong with character encode, but not, its right in any case. No type mismatches.
Where in this the logic?