javaandroidstringsplitstring-table

Split result not usable on android


I have a string that I split, it works perfectly until i want to use it : when I use a 'for' to read what a have in my String table I shows exactly what I want, but when I use if(MyStringTable[1] == "a") it isn't true, even though I just saw that MyStringTable[1] was equal to "a". My string table is "static" declared. I'm wondering if there is an invisible character or something that has been created with the split.


Solution

  • In terms of Strings, use .equals() in order to check if a String is equal to another. If one of them is a character, cast it previously to a String using .toString() to make it match this approach.