

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check if the string ends with specific substring in Java?
A String is an object that represents an immutable sequence of characters and cannot be changed once created. The java.lang.String class can be used to create a string object.
We can use the endsWith() method of String class to check whether a string ends with a specific string or not, it returns a boolean value true or false.
Syntax
public boolean endsWith(String prefix)
Example
public class StringEndsWithSubStringTest { public static void main(String[] args) { String str = "WelcomeToTutorialsPoint"; if(str.endsWith("Point")) { System.out.println("Ends with the specified word!"); } else { System.out.println("Does not end with the specified word!"); } } }
Output
Ends with the specified word!
- Related Questions & Answers
- How to check if the string begins with specific substring in Java?
- How to check if string or a substring of string ends with suffix in Python?
- Check if string ends with desired character in JavaScript
- How to check if a string ends with a specified Suffix string in Golang?
- How to check if string or a substring of string starts with substring in Python?
- Check if a string ends with given word in PHP
- Java Program to Check if a string contains a substring
- How to check if the string contains the specific word?
- Find rows where column value ends with a specific substring in MySQL?
- Check if substring present in string in Python
- How to check if a string contains a substring in Golang?
- Check whether a string ends with some other string - JavaScript
- How to check if a string contains a specific sub string?
- Java program to check if a Substring is present in a given String
- How do we check if a String contains a substring (ignoring case) in Java?
Advertisements