English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do i extract words from a sentence accepted from the user???

2007-02-24 20:58:24 · 2 answers · asked by kri91-16 2 in Computers & Internet Programming & Design

2 answers

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

This will put each word in the array. By using \\s+ it will split on any whitespace (multiple spaces, tabs, newline).

2007-02-25 11:20:43 · answer #1 · answered by rsmith985 3 · 0 0

use "split" or "substring"

first ull use the Keyboard.readString() ryt?? and after dat, ull asign a variable for it(ex input=keyboard.readString()).. then, create a new array (ex: word[]) then after dat

word[]=input.split(" ") // so u could separate the words

then u handle the rest^^

2007-02-25 05:08:32 · answer #2 · answered by idol 2 · 0 0

fedest.com, questions and answers