0
  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 and I need to check the last character of the string if he is a punctuation

MartinSchulze
  • 889
  • 1
  • 7
  • 14

1 Answers1

1

quote.charAt() Returns a character. "" defines a string.

Change to single quotes to define a character:

            quote.charAt(quote.length()-1)=='!' ||
            quote.charAt(quote.length()-1)=='?' ||
            quote.charAt(quote.length()-1)=='.'
Jens
  • 67,715
  • 15
  • 98
  • 113