[英]String[]tempString=multipleValues.split(“-”); but int the format for creating an array String[]array=new String[10];?
public void pushMany(String multipleValues){
String[]tempString=multipleValues.split("-");
for(int i=0;i<tempString.length;i++){
push(tempString [i]);
}
}
I am used to creating arrays using String[]array=new String[10]; 我习惯于使用String [] array = new String [10]创建数组。 or creating multidimensional arrays such as String[]array={"car","truck"}; 或创建多维数组,例如String [] array = {“ car”,“ truck”}; Therefore, I am not sure what is going on with this??? 因此,我不确定这是怎么回事??? Is it still assigned an array? 它仍然分配一个数组吗?
The String class has a method split String类具有方法拆分
public String[] split(String regex)
Quoting the java doc : 引用java doc :
Splits this string around matches of the given regular expression. 围绕给定正则表达式的匹配项拆分此字符串。
This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. 该方法的工作方式就像通过调用具有给定表达式且限制参数为零的二参数拆分方法。
Trailing empty strings are therefore not included in the resulting array. 因此,结尾的空字符串不包括在结果数组中。
so when you do split("-")
you are searching conincidences in the string that matches the "-" and the result is an array 因此,当您执行split("-")
您正在搜索与“-”相匹配的字符串中的一致性,并且结果是一个数组
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.