Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
From the perspective of the code that calls the method it doesn't matter at all, in Java parameters are always passed by value. Whether method code should be allowed to reassign parameter variables or not is primarily opinion based or just a matter of taste. With short code like this I personally don't see more disadvantages when modifying p0 compared to declaring another variable which might be considered additional noise. And with rather long or complex method code you have a different problem anyway: You're unable to quickly understand what it does anyway.
I agree. The arguments should remain consistent throughout the function and a local variable used in-favour of modifying the argument.
@AndreaLaforgia, in practice you should never "expect" too much about code; anything not declared
final
is modifiable.IMO best practice is make code intent clearer by getting into habit of using
final
modifier wherever appropriate - eg Unless you are going to changep0
then it should be declaredfinal p0
."Input will always be a non-negative integer."