Untitled
unknown
java
4 years ago
566 B
5
Indexable
public static void main(String[] args) {
String text = "Hello there buddy.Hello sir, nice to meet you. Nice weather we're having. Modi is doing very well as prime minister.";
String[] array = text.split(" ");
String temp = "";
List<String> list = new ArrayList<>();
for (String s : array) {
if ((temp + s).length() > 100) {
list.add(temp);
temp = "";
}
temp += s;
temp += " ";
}
System.out.println(list);
}Editor is loading...