Java: Read a string and return true if it ends with a specified string of length 2
58. Ends With Specific Two Characters
Write a Java program to read a string and return true if it ends with a specified string of length 2.
Visual Presentation:
Sample Solution:
Java Code:
Sample Output:
The given strings is: string The string containing ng at last: true The given strings is: strign The string containing ng at last: false
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Java program to check if a string concludes with a specified two-character substring and output a boolean value.
- Write a Java program to determine if the last two characters of a string match a given pair, ignoring case.
- Write a Java program to verify if a string ends with any of several given two-character combinations.
- Write a Java program to check a string's ending for a two-character pattern and handle strings shorter than two characters gracefully.
Go to:
PREV : Swap Last Two Characters.
NEXT : Begins With Color String.
Java Code Editor:
Improve this sample solution and post your code through Disqus
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.