Home » Strings(We Suck Every1) » Substring Example

Substring Example


public class SubstringExample{

<em id="__mceDel"> public static void main(String[] args){
 // strings like arrays starts from zero...

 String string = "Rajesh kumar";
 System.out.println("String : " + string);

 String substring = string.substring(3); // start from that till end...
 System.out.println("String after 3rd index:" + substring);

 substring = string.substring(1, 4);
 System.out.println("Substring (1,4): " +substring);

 substring = string.substring(1, 2); // starts from 1 till <2
 System.out.println("Substring (1,2): " +substring);
 }
}</em>


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Website

arpit tak

arpit tak

I like JAVA . I code. I chill. I blog.I eat. I sleep. I dream.

Personal Links

View Full Profile →

Followers

%d bloggers like this: