Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java String-examples String substring(int beginIndex)

Related Tutorials


 
 

Share on Google+Share on Google+

String substring(int beginIndex)

Advertisement
In this section, you will get the detailed explanation about the substring(int beginIndex) method of String class.

String substring(int beginIndex)

     

In this section, you will get the detailed explanation about the substring(int beginIndex) method of String class. We are going to use substring(int beginIndex) method of String class in Java. The description of the code is given below for the usage of the method.

Description of the code:

Here, you will get to know about the substring(int beginIndex) method through the following java program. In the program code given below, we have taken a String. To find a substring from the specified string, we have applied substring(int beginIndex) method and then we have passed the index number to that to find the specified substring from the beginning of that index number as shown in the output. 

NOTE: This method returns a new string from the specified string that is a substring of it.

Here is the code of the program: 

public class StrSearch{
  public static void main(String args[]){
  String s = "Bonjour";
  //String begin = 1;
  String t = s.substring(1)
  System.out.println(t);
  }
}  

Output of the program:

C:\unique>javac StrSearch.java

C:\unique>java StrSearch
onjour

C:\unique>

Download this example.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 21, 2007

Related Tutorials

Discuss: String substring(int beginIndex)   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com