0
我想传递一个布尔值数组到一个方法。此代码的工作:如何将新数组作为参数传递给Java中的方法?
void checkResults(boolean[] isChecked){
//Do something
}
boolean[] isChecked= {true, true};
checkResults(isChecked); //works
但下面的所有努力都失败了:
checkResults(new {true, true}); //Compile time error
checkResults({true, true}); //Compile time error
checkResults(true, true); //Compile time error (this one is obvious)
有没有一种方法来创建参数数组并传递给方法在一条线?
你试过checkResults(new boolean [] {true,true})吗? – VatsalSura