I want to write a function in java which has default parameters, but if I pass value to those parameters then it should take those values in place of those default parameters. I know how to write the function in Python. But I want to implement the exact same function(or method) in Java.
This is the sample python code
def myFunc(name, std = 3, rollNo = 61, branch = "CSE"):
print("My name is %s, I read in class %d, my roll no is %d, my branch is %s" %(name,
std, rollNo, branch))
myFunc("hacker", 3)
myFunc("hacker", 3, 60)
myFunc("hacker")
This the output of the python code
My name is hacker, I read in class 3, my roll no is 61, my branch is CSE
My name is hacker, I read in class 3, my roll no is 60, my branch is CSE
My name is hacker, I read in class 3, my roll no is 61, my branch is CSE
I want to write a function in Java that does the exact same thing.