value of the parameter of a method
What will be the value of the pa开发者_如何学Crameter i.e. private static boolean ask(int i){int te = 8 + i;}
Coz i notice the 'i' was use in the method. I just wonder what will be the value of that 'i' and/or what's the use of it?
The value of i
will be whatever the caller of the method passed into the method call.
So if someone called
ask(5);
then i
will be 5
within that specific invocation. Parameter values are specific to the particular invocation of the method, must be supplied each time and will be evaluated anew each time. Even if multiple threads are calling the method simultaneously, each will see the value of i
that they passed in.
value of te will be 8 + value of i but it will not compile since there is a missing return statement and the method says a boolean is returned
精彩评论