Learning language is easy but learning basics is difficult
Does the String object in that language not have an "endsWith()" method? If it has one, it would be a lot easier to use that than to write your own code.
When the app crashed? With + or without + ?
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
ian bilgaen wrote:The problem with endsWith() method is that it only works with suffix and not with single characters.
Paul Clapham wrote:Can you post a link to the documentation which says the parameter for endsWidth has to be a String of length greater than 1?
That isn't how it works in Java and I'd be very surprised if Android had such a requirement.
Android API Doc wrote:endsWith
added in API level 1
boolean endsWith (String suffix)
Tests if this string ends with the specified suffix.
Parameters
suffix String: the suffix.
Returns
boolean true if the character sequence represented by the argument is a suffix of the character sequence represented by this object; false otherwise.
Note that the result will be true if the argument is the empty string or is equal to this String object as determined by the equals(Object) method.
Java API Doc wrote:endsWith
public boolean endsWith(String suffix)
Tests if this string ends with the specified suffix.
Parameters:
suffix - the suffix.
Returns:
true if the character sequence represented by the argument is a suffix of the character sequence represented by this object; false otherwise.
Note that the result will be true if the argument is the empty string or is equal to this String object as determined by the equals(Object) method.
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
Paul Clapham wrote:That's what I more or less expected. So Ian, I don't really see a barrier to using the endsWith() method to see if a String ends with the "+" character. But it seems like you do see a barrier, so... what's that barrier?
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|