Sponsered Links
Categories
Sponsered Links

Java string matches method example

 

This example illustrates Java string matches method example. In this example method just matches the String value to the specified value in the parentheses and generates boolean values. Method not get the same values therefore it returns false. The method gets the same values but not able to match there allignments therefore it returns false. Finally, method gets the same values with precise allignments therefore it returns true.
 

public class StringMatches {
  public static void main(String args[]) {
   
    String str = "string", str1 = "matches";
    boolean result = str1.matches("jsp");
   
    System.out.println("Method returns 'false':  " + result);
   
    result = str.matches("string");
    System.out.println("Method returns 'false':  " + result);
   
    result = str.matches("string");
    System.out.println("Method returns 'true':  " + result);
  }
}

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved