Java 如何将字符串拆分为字符串

Java 如何将字符串拆分为字符串,java,android,string,split,Java,Android,String,Split,我有一个字符串,例如:“Adam”,我会将一个字符串拆分成一个由单个字符串组成的数组。(“a”、“d”、“a”、“m”) 你的建议?String str=“Adam”; String str = "Adam"; TextView[] textViews = new TextView[4]; textViews[0] = textView1; textViews[1] = textView2; textViews[2] = textView3; textViews[3] = textView4;

我有一个字符串,例如:“Adam”,我会将一个字符串拆分成一个由单个字符串组成的数组。(“a”、“d”、“a”、“m”)

你的建议?

String str=“Adam”;
String str = "Adam";
TextView[] textViews = new TextView[4];
textViews[0] = textView1;
textViews[1] = textView2;
textViews[2] = textView3;
textViews[3] = textView4;
for(int i=0; i<str.length(); i++) {
    textViews[i] = str.charAt(i);
}
TextView[]TextView=新建TextView[4]; textViews[0]=textView1; textViews[1]=textView2; textViews[2]=textView3; textViews[3]=textView4; 对于(int i=0;i 从文件:

公共字符串[]拆分(字符串正则表达式)

围绕给定正则表达式的匹配项拆分此字符串

此方法的工作方式类似于通过调用具有 给定的表达式和限制参数为零。尾部为空 因此,结果数组中不包括字符串

例如,字符串“boo:and:foo”产生以下结果 用这些表达:

Regex     Result
:     { "boo", "and", "foo" }
o     { "b", "", ":and:f" }
参数: regex-定界正则表达式返回: 通过围绕给定正则表达式的匹配项拆分此字符串而计算的字符串数组


为什么会被否决?
Regex     Result
:     { "boo", "and", "foo" }
o     { "b", "", ":and:f" }