You are here: Home / Topics / subString() method example in stringBuffer in Java

subString() method example in stringBuffer in Java

Filed under: Java on 2023-08-23 18:57:52

// Program to explain the following StringBuffer function :
//String substring( int startIndex )
//String substring( int startIndex, int endIndex )

class  Msubstring1
{
public static void main( String args[ ] )
{
 StringBuffer sb1 = new StringBuffer( "Java Programming Examples." );
 
 System.out.println( " String = " + sb1 );
 
 String s1 = sb1.substring( 5 );
 System.out.println( " String = " + s1 );  

 String s2 = sb1.substring( 5, 14 );
 System.out.println( " String = " + s2 );
}
}


Output:

String = Java Programming Examples.
String = Programming Examples.
String = Programmi

About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.