Java String split example

public class StringSplitExample {
	public static void main(String[] args) {
		String str = "hello this is string split example";
		//splitting string with space
		String[] strings = str.split("\\ ");
		//total number of sub-strings
		System.out.println("Total number of sub-strings : "+strings.length);
		for (int i = 0; i < strings.length; i++) {
Total number of sub-strings : 6 hello this is string split example

Related Examples

Write a program to check if an input String is Palindrome or not?
Calculate the factorial of a given number using Java?
How to reverse a number in Java?
Write a program to convert from decimal to binary?
Producer Consumer Example in Thread
Write a program to reverse a String?

Receive Latest Java Examples in Your Email: