How to use BigInteger in Java - 2
May 31, 2023
1 min
String has a startsWith() method. This is a method used to compare the starting strings of the String value. That is, it functions to check whether the string starts with a designated single character(s).
public class Test {public static void main(String[] args) {String str = "code-journey.com";System.out.println(str.startsWith("code")); // trueSystem.out.println(str.startsWith("Code")); // falseSystem.out.println(str.startsWith("com")); // falseSystem.out.println(str.startsWith("o")); // falseSystem.out.println(str.startsWith("c")); // true}}
Of course it’s a baby, but it’s case sensitive.