Convert String to String Array with split method - Java Language Basics

Java examples for Language Basics:String

Description

Convert String to String Array with split method

Demo Code


 
public class Main {
       /*from w  w  w. jav  a2  s. com*/
        public static void main(String args[]){
                String str = "Java String to String Array Example";
                String strArray[] = str.split(" ");
               
                System.out.println("String converted to String array");
               
                for(int i=0; i < strArray.length; i++){
                   System.out.println(strArray[i]);
                }
        }
       
}

Result


Related Tutorials