Responsive Ads Here

Wednesday, April 27, 2016

Converting a sentence string to a string array of words in Java


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
public class SentenceToWord {

 public static void main(String[] args) {

  String a = new String("My name is Shadhin");

  String[] words = a.split("\\s+");

  for (int i = 0; i < words.length; i++) {
   System.out.println(words[i] + " ");
  }

 }

}

No comments:

Post a Comment

php4

<?php    // Start the session  session_start();  ?>  <!DOCTYPE html>  <html>  <head>       <link rel=&q...