How SubString Works in Java?

Ques:  How SubString works in Java
ans:Substring is used to get chunk of text from the String...to get the substring ,we need starting index and last index.Starting index defines the starting position from where the first letter of the substring starts.and last letter is last index-1.
for example
String a="Hello";
System.out.println(a.subString(1,3));

output:el

we can also use only starting index
for example:
String FullName = "Bill Gates";
String test = FullName.substring( 2 );

output:ll Gates

This time, we only have 1 number between the round brackets of substring. Now, Java will start at character two in the string FirstName, and then grab the characters from position 2 right to the end of the string.

People who read this post also read :



1 comments:

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here.
Kindly keep blogging. If anyone wants to become a Java developer learn from Java EE Online Training from India.
or learn thru Java EE Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More