我刚接触Java,我对数组初始化的程序感到震惊,因为它不工作并且包含一些垃圾。这就是我正在做的事情:
char[] expArray = new char[expEv.length]; //expEv.length is int - expEv is another array
//I have tried all following but not working
expArray = {'\0'}; // error i get: Array constants can only be used in initializers
expArray = {'',};
expArray = {'\0'};
System.out.println("array value: " + expArray); // prints " array value: [C@1cd761a "
编辑:我也尝试过使用char[] expArray = new char[expEv.length] {'\0'};
,但这不起作用
请帮助我并解释上下文的数组初始化。