[Java] function如何傳不定參數

private void MyParameterizedFunction(String param1, int param2, Boolean... params) 
{
assert params.length <= 1;
boolean param3 = params.length > 0 ? params[0].booleanValue() : false;
}
private void test()
{
MyParameterizedFunction("", 1);
}

Reference: http://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html


Originally published at vincewiki.blogspot.com on June 28, 2017.

Like what you read? Give Vince Huang a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.