4
Dacexi
7y

Wait, what am i missing? Learning java and got charSequence cannot be converted to string. Isn't a string a sequence of characters??? 🤔🤔🤔

Comments
  • 0
    A String is a char sequence, but there are also others like stringbuffer. just use charseq.toString()
  • 0
    @timihg i did. Thats when i got the error
  • 0
    charsequence is an interface, so it doesnt necessarily implement the toString method. cant you just use a string instead? it implements the charsequence interface
  • 0
    @timihg trying to get something form android and it returns a charSequence
  • 0
    Maybe you can use a StringBuilder and pass the charsequence in?
  • 1
    Just try checking if it's null and if length returns a value >0. If both is true to string should work. Else try the construction worker method and iterate over the whole sequence and add char by char with charAt.
Add Comment