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:57:38 · 2 answers · asked by kri91-16 2 in Computers & Internet Programming & Design

2 answers

u can use split function of String class to split the string with respect to " ". this will split the string into words and will return an array of string that is word. Beware: Do u have a java 1.4 version or above. because this function is there in java since that version only. so if u are using a 1.3 version than that function is not supported. then better install a new JDK.

String s=" this is the test of breaking sentence";
String[] words = s.split(" "); // u r here

this should solve ur problem.

2007-02-24 21:48:59 · answer #1 · answered by Anonymous · 0 0

Use string.length and a for loop to go through the string to find the characters that you are looking for. Then use the substring method to remove that substring.

2007-02-24 21:35:28 · answer #2 · answered by josh.weissbock 3 · 0 0

fedest.com, questions and answers