How to check if a substring match the beginning of a string in Java

1 Answer

0 votes
public class Main {
   public static void main(String args[]) {
      String str = "Java run desktop applications";
      String substr = "java";
      
      System.out.println(str.toLowerCase().startsWith(substr.toLowerCase()));
   }
}
  
  
/*
run:
  
true
  
*/

 



answered Feb 9, 2025 by avibootz
...