+ 6

I have a question about function argument.

What's the difference between funcA and funcB ? void funcA(int a){ System.out.print(a); } void funcB(int b){ int input = b; System.out.print(input); } Do I need to declare a new variable for argument ? Or I just can use the argument directly ? Which is better ?

6th Sep 2017, 12:14 PM
Corey
Corey - avatar
2 Answers
+ 3
@Kuanlin Chen, yes, I believe it is for the sake of efficiency. You can of course create variables in a function if it is necessary, but in the case on your sample code it was not necessary.
6th Sep 2017, 1:58 PM
Ipang
+ 5
Is it because of efficiency ?
6th Sep 2017, 12:43 PM
Corey
Corey - avatar