Answers for "build a string array into a sentence java"

0

turning a sentence to an array java

String s = "This is a sample sentence.";
String[] words = s.split("\s+");
for (int i = 0; i < words.length; i++) {
    // You may want to check for a non-word character before blindly
    // performing a replacement
    // It may also be necessary to adjust the character class
    words[i] = words[i].replaceAll("[^\w]", "");
}
Posted by: Guest on October-21-2020
0

how to convert a sentence into string array in java

String str = "This is a simple sentence";
String[] strgs = str.split(" ");
Posted by: Guest on August-24-2020

Code answers related to "build a string array into a sentence java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language