Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

split the argument String and add the tokens into a list

public List<String> getTokens(String str) {
    List<String> tokens = new ArrayList<>();
    StringTokenizer tokenizer = new StringTokenizer(str, ",");
    while (tokenizer.hasMoreElements()) {
        tokens.add(tokenizer.nextToken());
    }
    return tokens;
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #split #argument #String #add #tokens #list
ADD COMMENT
Topic
Name
8+2 =