What is the equivalent to Python's pass
in Java? I realize that I could use continue
or not complete the body of a statement to achieve that effect, but I like having a pass
statement.
There is no (strict) equivalent since in java you have to specify the return type for the method in its declaration which is then checked against a computed type of the following the return statement.
Simply remove else { return false } . Notice that there is a big diference between else {} and else {return false} In the second case the function will stop in the else scenario.
Object variables in Java always point to the real object in the memory heap. A mutable object's value can be changed when it is passed to a method. An immutable object's value cannot be changed, even if it is passed a new value. “Passing by value” refers to passing a copy of the value.
Just use a semi-colon ;
, it has the same effect.
If you want something noticeable, you can use
assert true;
This will allow you to have something that a reader can recognize or that can be searched for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With