How to check whether a String matches with a specified substring using the Java matches() method
Coding River
How to check whether a String matches with a specified substring using the Java matches() method
In this video, we will discuss on the Java matches() method, which can be used to check whether a String matches with a specified regular expression. This method returns a Boolean value whenever it is executed. It returns true if there is a match and false if there is no match. Let me show you how to use this method with the help of an example
String str = "Coding River"; System.out.println(str.matches("Coding River")); This statement will return "true"
System.out.println(str.matches("Coding")); This statement will return false
System.out.println(str.matches("(.)Coding(.)")); This statement will return true
System.out.println(str.matches("(.)Coder(.)")); This statement will return false, because we have changed the characters, so they are not matching a String any more
#codingriver #javatutorial #javamethod #java ... https://www.youtube.com/watch?v=tP7MQ2hacoQ
10283137 Bytes