Java String match exact String value

Description

Java String match exact String value

public class Main {

   public static void main(String[] args) {

      String str = "Here is a long String...";
      // This will result in a TRUE since it is an exact match
      boolean result = str.matches("Here is a long String...");

      System.out.println(result);

      // This will result in FALSE since the entire String does not match
      result = str.matches("Here is a long String...adf");

      System.out.println(result);
   }/*from w  ww . j  a  v  a  2  s . c  o  m*/

}



PreviousNext

Related