How To Check Whether A Given String Ends With A Specified Suffix Using The endsWith() Method
Coding River
How To Check Whether A Given String Ends With A Specified Suffix Using The endsWith() Method
In this video, we will talk about the Java endsWith() method, which is used to check whether a given String ends with a specified suffix. This method returns a boolean value when executed. It returns true if the specified suffix is found at the end of the given String and it returns false if the specified suffix is not found at the end of the String
Here is an example
String str1 = “I love programming”; String str2 = “programing”;
Since the method returns a Boolean value
boolean returned_value = str1.endsWith(str2); System.out.println(“Does str1 end with “ + str2 + “? “ + returned_value);
If we run this program, the method will evaluate to true, which means that our String str1 ends with the string value stored in str2
Try using uppercase characters in str2 to see if the method is case sensitive
#codingriver #java #programming ... https://www.youtube.com/watch?v=tdkrihJKguM
6466601 Bytes