Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Checking end of a String

843789Jan 29 2010 — edited Jan 29 2010
I have a relatively simple question, but I've been looking since yesterday and can't find the answer to my question.

I'm writing a program that reads a sentence using a dialog box. Depending on the last character of the sentence, output another dialog box identifying the sentence as declarative ( ends with a period ), interrogative ( ends with a question mark ), exclamatory ( ends with an exclamation point ), or other.

I set the JOptionPane to create the dialog box and ask the user for their sentence input. Then, I will create another JOptionPane to grab that sentence and output whether it is declarative, interrogative, etc.....

What I'm unsure about is how do I read the end of String input to see what type of sentence it is? I figured once I was on the right path to checking the end of the string I would create an If statement to facilitate that check and output the result. Any guidance is appreciated. Thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 26 2010
Added on Jan 29 2010
6 comments
767 views