Android Application Development Tutorial - 28 - Comparing Strings with else if
Top Comments
All Comments (37)
-
but if strings got the same contain, they just take the same place in memory
example, if u got 20 strings and "lol" in them, it just will create one String object
so you can check contain of the strings
-
@Mr1159pm I'be been coding for years and your comment made me understand primitives vs objects from a new perspective.
-
why can't you use equals() instead of contentEquals()? What's the difference... for the most part?
-
Excelent Tutorial, ALL..
-
this is a string, for the most part.....HAHAHAHA... love it.
-
@joannis11 Wrong. That will simply compare if they are initialized in the same way. Since String is a class and not a variable type, per se, you have to use a method to compare them.
-
Dude, we know Java already.
-
@vilham437 Or .equals()
-
"Hey, if you need anyone to set up some buttons in Java .. I'm you're man!"
that's gonna be my new pickup line for sure.
-
@vilham437 This is true only for java. In c# or Python you can use == to compare Strings
I really like these tutorials...for the most part.
kopilatis10 6 months ago in playlist TheNewBoston - Android 49
@xXxDiukexXx you cannot use == to compare the contents of strings or any other objects because == with objects is checking to see if they have the same location in memory instead of checking to see if the strings contain the same word. The .contentEquals() method compares the actual strings instead of the memory location
vilham437 6 months ago 25