Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用正则表达式的Java数组孔_Java_Regex_Arrays_Delimiter - Fatal编程技术网

使用正则表达式的Java数组孔

使用正则表达式的Java数组孔,java,regex,arrays,delimiter,Java,Regex,Arrays,Delimiter,有人能告诉我为什么这个代码在数组[0][4]上有一个洞吗 public class Random{ public static void main (String []args){ String [][] array={{"This is a test. A hole here"}}; for(int i=0;i<array.length;i++){ String temp=array[i][0];

有人能告诉我为什么这个代码在数组[0][4]上有一个洞吗

public class Random{ 

    public static void main (String []args){

        String [][] array={{"This is a test. A hole here"}};

        for(int i=0;i<array.length;i++){
            String temp=array[i][0];

            array[i]=temp.split("[\\:., ]");
        }

        System.out.print(array[0][4]);
    }
}
公共类随机{
公共静态void main(字符串[]args){
字符串[][]数组={{“这是一个测试。这里有一个洞”};

对于(int i=0;i和
数组[i]=temp.split(“[\\:,]”;
您的字符串在此处拆分:

This is a test. A hole here
    ^  ^ ^    ^^ ^    ^
因此,在
数组[4]
中得到一个空字符串


使用
array[i]=temp.split(“[\\:,]+”;
它将把“.”合并成一个“分割点”,因此它不会在这两个点之间分割

This is a test. A hole here
    ^  ^ ^    ^^ ^    ^