Share on Google+Share on Google+

Java split string example

This section illustrates you the use of split() method.

Java split string example

This section illustrates you the use of split() method.

The String class has provide several methods for examining the individual characters, for extracting substrings,  for comparing strings, for searching strings, for converting string to upper case and lowercase etc. The method split() is one of them. As the name suggests, this method can split the string into the given format and will return the string in the form of string array. Actually, it is based on regex expression with some characters which have a special meaning in a regex expression.

Here is the code:

class StringSplitExample {
	public static void main(String[] args) {
		String st = "Hello_World";
		String str[] = st.split("_");
		for (int i = 0; i < str.length; i++) {




Posted on: January 14, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

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.