What does ‘public static void’ mean in Java?

It’s three completely different things: public means that the method is visible and can be called from other objects of other types. Other alternatives are private, protected, package and package-private. See here for more details. static means that the method is associated with the class, not a specific instance (object) of that class. This means that you can call a static method without creating … Read more

Does Java support default parameter values?

No, the structure you found is how Java handles it (that is, with overloading instead of default parameters). For constructors, See Effective Java: Programming Language Guide’s Item 1 tip (Consider static factory methods instead of constructors) if the overloading is getting complicated. For other methods, renaming some cases or using a parameter object can help. This is … Read more

Does Java support default parameter values?

No, the structure you found is how Java handles it (that is, with overloading instead of default parameters). For constructors, See Effective Java: Programming Language Guide’s Item 1 tip (Consider static factory methods instead of constructors) if the overloading is getting complicated. For other methods, renaming some cases or using a parameter object can help. This is … Read more

Is Java “pass-by-reference” or “pass-by-value”?

Java is always pass-by-value. Unfortunately, when we deal with objects we are really dealing with object-handles called references which are passed-by-value as well. This terminology and semantics easily confuse many beginners. It goes like this: In the example above aDog.getName() will still return “Max”. The value aDog within main is not changed in the function foo with the Dog “Fifi” as the object reference is passed by value. If it … Read more