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

split() method example in Java

Filed under: Java on 2023-08-23 18:51:06

// Program to explain the following String function :
// String[ ] split( Stirng regExp )

class  Msplit
{
public static void main( String args[ ] )
{
 String s1 = new String( "Java Programming Examples" );

 String s2[ ] = s1.split( " " );

 System.out.println( " String = " + s2[0] );
 System.out.println( " String = " + s2[1] );
 System.out.println( " String = " + s2[2] );
}
}


Output:

 String = Java
 String = Programming
 String = Examples

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