Java String substring()The java string substring() method returns a part of the string. We pass begin index and end index number position in the java substring method where start index is inclusive and end index is exclusive. In other words, start index starts from 0 whereas end index starts from 1. There are two types of substring methods in java string. Internal implementationSignatureIf you don't specify endIndex, java substring() method will return all the characters from startIndex. ParametersstartIndex : starting index is inclusive endIndex : ending index is exclusive Returnsspecified string ThrowsStringIndexOutOfBoundsException if start index is negative value or end index is lower than starting index. Java String substring() method exampleva vatpoint Java String substring() Method Example 2Javatpoint point Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 5, end 15, length 10 Next TopicJava String toCharArray()
|