Java Strings

Java String startsWith() method with examples

This post will discuss the startsWith() method of the String class in detail. startsWith() helps us determine whether the string starts with the specified string. We have also kept some fun what-if scenarios at the end of the post. In Java, we have two overloaded startsWith() methods – public boolean startsWith(String prefix) public boolean startsWith(String …

Java String startsWith() method with examples Read More »

Java String substring() method with examples

The Java String substring() method returns a part of the String and there are two overloaded substring() methods in Java. public String substring(int beginIndex) public String substring(int beginIndex, int endIndex) Let’s look at both of the methods one by one public String substring(int beginIndex) What does it do? It takes an index into the argument …

Java String substring() method with examples Read More »