by Dinesh Thakur Category: Stream

In Split Function Java Example, the string t is split into pieces (wherever space has occurred in it) with the help of split() method and all its pieces are then stored in the string array h. Then, the length of the string h is computed by length() function and the loop is invoked in reverse to display the tokens stored in string array h in reverse order.


class SplitFunction
       public static void main(String args[]) throws IOException
             BufferedReader bf=new BufferedReader(new InputStreamReader(;
             String t;
             int i,n;
             System.out.println("Enter a line of text");
             String[] h = t.split(" ");
             System.out.println("the words in reverse order are");

Split Function in Java with Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles