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 (System.in);
String a = "";
System.out.println(" Enter Your Story Here !..... ");
a = input.nextLine();
String [] words = a.split(" ");
for (String word : words)
{
System.out.println(word);
}
}
}
Output of the Program
Split Word in String |
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.
0 comments:
Post a Comment