Default Parameter Values in Java

Published: Aug 10, 2018
Updated: May 3, 2021

I’m used to C#, so if I want a parameter to have a default value, it can be done like this.

private static void sayHi(string message = "Hi") 

But what about Java? It can be done as well, and one way is to use method overloading.

private static void sayHi(String message) {

private static void sayHi() {

Shoutout to this stackoverflow post.