For the API (Android SDK API version 8) functions whose definitions list character sequence parameters, I can feed the function String instead. Best part is that they work the same way, no hassle, no warnings.
Is there a difference between the two types? And more importantly, is there an inherent danger if I send the function a String instead of a character sequence???
Thanks for any clarifications!!! :D
Is there a difference between the two types?
Yes. String is a class, and CharSequence is an interface. If a method accepts a CharSequence, it only requires the argument to implement the methods in the interface, which gives a greater flexibility, than if it would accept only a String.
The following API classes implement CharSequence: CharBuffer, Segment, String, StringBuffer, StringBuilder. That is, a String is a CharSequence, and can thus be passed to a method that accepts a CharSequence.
And more importantly, is there an inherent danger if I send the function a String instead of a character sequence???
No, there is no danger. String properly implements CharSequence, and that's all the method will require to function properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With