![]() The method throws an IndexOutOfBoundException when the startIndex is less than zero or startIndex is greater than endIndex or endIndex is greater than length of String. This method returns new String object containing the substring of the given string from specified startIndex to endIndex. public String substring(int startIndex, int endIndex):.The method throws an IndexOutOfBoundException when the startIndex is larger than the length of String or less than zero. This method returns new String object containing the substring of the given string from specified startIndex (inclusive). public String substring(int startIndex):.You can get substring from the given String object by one of the two methods: Suppose the string is " computer", then the substring will be com, compu, ter, etc. In case of substring() method startIndex is inclusive and endIndex is exclusive. ![]() ![]() Java String class provides the built-in substring() method that extract a substring from the given string by using the index values passed as an argument. In other words, substring is a subset of another String. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |