Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
I have a Array List with HashMap
I have to retrieve some data from this Array e compare using an IF-STATMENT, like the code below:
The problem is: I can't get enter the IF-STATEMENT. I'm sure the values are exact the same. I don't know what to do. Thanks. | ||||
When comparing Strings use equals() So in your conditional it should be | |||
When you compare reference types in Java (and Android) you need to use the
| |||
Use equals("lamp") or equalsIgnoreCase("lamp") method to co0mpare two Strings.
| |||
Try this:
Strings are compared using | |||
Use
The operator, ==, tests to see if two object reference variables refer to the exact same instance of an object. The method, .equals(), tests to see if the two objects being compared to each other are equivalent -- but they need not be the exact same instance of the same object. http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html Check the equals method in the link above | ||||
lang-java
.
stackoverflow.comm
No comments:
Post a Comment