Check out example codes for "trim and split java". It will help you in understanding the concepts better.

Code Example 1

package com.zetcode;

import java.util.Arrays;

public class SplitStringTrimEx {

    public static void main(String[] args) {

        var input = " wood, falcon\t, sky, forest\n";

        var output = input.trim().split("\\s*,\\s*");

        Arrays.stream(output).forEach(System.out::println);
    }
}

Learn ReactJs, React Native from akashmittal.com