You could do this:
String str = "...";
List<String> elephantList = Arrays.asList(str.split(","));
Basically the .split()
method will split the string according to (in this case) delimiter you are passing and will return an array of strings.
However, you seem to be after a List of Strings rather than an array, so the array must be turned into a list by using the Arrays.asList()
utility. Just as an FYI you could also do something like so:
String str = "...";
ArrayList<String> elephantList = (ArrayList<String>)Arrays.asList(str.split(","));
But it is usually better practice to program to an interface rather than to an actual concrete implementation, so I would recommend the 1st option.
2014年11月24日 ... 利用split把字符串按照指定的分割符进行分割,然后返回字符串数组,下面是string. split的用法 ... 连字符,比如:String str="Java string-split#test",可以用Str.split(" |-|#") 把每个字符串分开; ... String类的split方法可以将字符串按照特定的分隔符拆分成 字符串数组。 ... Java split 根据指定字符串分隔成list数组的用法.
Jan 23, 2017 ... Splitting a String on delimiter as the pipe is a little bit tricky becuase the most obvious solution will not work, given pipe is a special character in Java regular expression. ... 3rd Example - splitting a comma-separated String.
Java 实例- 字符串分割Java 实例以下实例使用了split(string) 方法通过指定分隔符将 字符串分割为数组: JavaStringSplitEmp.java 文件[mycode3 type='java'] public ...
2013年1月15日 ... 把三个都分隔出来,可以用String.split("and|or"); 3、public String[] split(String regex,int limit)根据匹配给定的正则表达式来拆分此字符串。
3 days ago ... The method split() splits a String into multiple Strings given the delimiter that separates them. The returned object is an array which contains the ...
2018年12月15日 ... 分割规则通常是指定某个分隔符,根据字符串内部的分隔符将字符串进行分割, 例如逗号、空格等等都可以作为字符串的分隔符。正好String类型 ...
2015年4月22日 ... 很好理解,就是把字符串用 split(" +") 的方法拆开String数组,然后将这个数组倒序 拼接在一起。 ... 字符串以空格为分隔符,怎么将他们分开? 01-13 ... java字符串反 转,逆序输出(句子反转,单词不翻转). 01-14 ... 阿里巴巴的实习生笔试题,实现 将字符串按特定分隔符进行反转,如“www.taobao.com”,反转后 ...
2018年11月26日 ... 3、如果在一个字符串中有多个分隔符,可以用"|"作为连字符,比如:String str="Java string-split#test",可以用Str.split(" |-|#")把每个字符串分开;.
... .split() method will split the string according to (in this case) delimiter ... @ GurselKoca answer to Removing whitespace from strings in Java).
Feb 13, 2020 ... Splits a given string according to a given delimiter and returns a string array with the contained substrings. Optionally, a specific substring can ...
2017年9月27日 ... 多个分隔符使用'|'分开,例如:. String str = "abc ... 相关推荐. StringUtils 根据指定 的分隔符进行截取 ... java的split方法可以实现同时使用多个分隔符劈开字符串方法 : ... 需求说明: 1、在项目中需要对一个特定的字符串进行分割,获取分隔后的 数据。 2、字符串 ... 重复使用的话就可以把字符串分割开了。关键字: ...
在Swift中,如果需要把一个字符串根据特定的分隔符拆分(split)成字符串 ... java String中文字符串分割成一定长度的字符串数组/** * 几个字一组变量控制大于零有 ...
2018年9月22日 ... 本文讨论Java中的split函数.split()是一个用来切分字符串的函数, 相信大家都用过, ... 最基本的用法当然就是用指定字符串直接分割代码, 一般来说是一个符号之类的, ... 如何获取一个句子中的所有单词(也就是以非单词作为分隔符) ?
Java中根据某一分隔符拆分字符串在Java学习过程中常常需要根据某一特定的分隔 符来拆分字符串,这里演示一下: 例如:输入字符串2015-12-21需要根据“-”来拆 ...
Splitting a string delimited by pipe (|) is a little bit tricky. ... Variants and splits this string around matches of the given string according to the split size, examples ...
In Java, delimiters are the characters that split (separate) the string into tokens. Java allows ... It splits the string according to specified regular expression regex.
Feb 19, 2021 ... The StrSplit() method splits a String into an array of substrings. ... method allows you to break a string based on specific Java string delimiter.
Nov 25, 2020 ... Almost all programming languages, provide function split a string by some delimiter. In C/C++: // Splits str[] according to given delimiters.
C = strsplit( str , delimiter ) splits str at the delimiters specified by delimiter . If str has consecutive delimiters, with no other characters between them, then strsplit ...
Learn to split string into arraylist using single delimiter or multiple delimiters. Guava Splitter is ... Before using this data further, it must be splitted to separate string tokens. We will ... You need to do these specific handling token by token basis.