Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
566 B
2
Indexable
Never
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);
    }