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