I am trying to create a method which should accept minimum one and maximum two parameters. First parameter is must but second is optional.
I've tried following
myFunction(String param1, String param2){
}
But in this case both parameter need to be passed, which I don't want.
myFunction(String... params){
}
In this case it can accept more than two parameters also, which also I don't want.
Could someone please tell if it's accomplished in java?