Monday, 28 July 2014

How to spilt Words in a string in java

Structure of the Problem Requirements 

String has many methods in Java and spilt string into words is one of them. In this Problem the user will enter a string and program spilt its words on the bases of spaces. An array of string is use to store these words and display them one by one.

Source Code

package com.ancodingpoint.ww.w;

import java.util.Scanner;

public class String_Function {

    public static void main(String[] args) {
        Scanner input = new Scanner (;
        String a = "";
       System.out.println(" Enter Your Story Here !..... ");
        a = input.nextLine();
       String [] words = a.split(" ");
       for (String word :  words)

Output of the Program

Java String Programming
Split Word in String

Share it Please

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.


Post a Comment