java substring method

A piece of string is called java sub­string. sub­string is a sub­set of anoth­er string. In the event of sub­string startIn­dex is inclu­sive and endIn­dex is exclu­sive.

Syntax-

pub­lic String substring(int beginIn­dex)
pub­lic String substring(int beginIn­dex, int endIn­dex)

In this instruc­tion­al exer­cise I will dis­cuss the java sub­string() method. Under­stand that the pri­ma­ry char­ac­ter of a string is sit­u­at­ed at the 0 index. The sub­string() method is over­loaded and has two unique sig­na­tures. The substring(int beginIn­dex) just returns every remain­ing char­ac­ter at and includ­ing the char­ac­ter at the pre­de­ter­mined index. For exam­ple :

The substring(int beginIn­dex, int endIn­dex) is a lit­tle more com­pli­cat­ed this method returns new String object con­tain­ing the sub­string of the giv­en string from spec­i­fied startIn­dex to endIn­dex. The first para­me­ter edu­cates the sub­string method to start return­ing char­ac­ters at and includ­ing the char­ac­ter at the pre­de­ter­mined index. The sec­ond para­me­ter trains the sub­string method to quit return­ing char­ac­ters bar­ring the char­ac­ter at the pre­de­fined index.(Read Also : String com­pare­to)

For instance : 

Program -

java substring