java incomparable type when using charAt() -
this question has answer here:
public void keypressed(keyevent e) { if(e.getkeycode()==keyevent.vk_enter){ input.seteditable(false); string quote=input.gettext(); input.settext(""); addtext("you:\t"+quote); quote=quote.trim(); while( quote.charat(quote.length()-1)=="!" || quote.charat(quote.length()-1)=="?" || quote.charat(quote.length()-1)=="." ){ quote=quote.substring(0,quote.length()-1); } quote=quote.trim(); } it's giving me incomparable type on quote.charat , need check last character of string if punctuation
quote.charat() returns character. "" defines string.
change single quotes define character:
quote.charat(quote.length()-1)=='!' || quote.charat(quote.length()-1)=='?' || quote.charat(quote.length()-1)=='.'
Comments
Post a Comment