Is it possible to do something like this
private void function(Integer[] a, String str = "")
like in PHP. If I don't provide str, it will just be empty. In PHP it's possible, in JAVA it gives me error. Or the only solution here is to create two methods like this?
private void function(Integer[] a, String str)
private void function(Integer[] a)
Answer
Exacly, there is no other option than:
private void function(Integer[] a, String str) {
// ...
}
private void function(Integer[] a) {
function(a, "");
}
No comments:
Post a Comment