我这里有两个功能。它们都有相同的用途,但它们的参数设置不同。哪个更快?提前致谢。
//This function's purpose is to print x + y times.
//total = x + y
public void function(int total){
for (int i = 0; i < total; i++){
System.out.println("Hello.");
}
}
//This function is the same as the above.
//The value is calculated within a "for" loop
public void function(int x, int y){
for (int i = 0; i < x + y; i++){
System.out.println("Hello.");
}
}
public void main(String[] arg){
//Initial variables.
int x = 4;
int y = 6;
//First function call
function(x + y);
//Second function call
function(x, y);
}