Is it possible to declare default argument in Java in String?
81,632
Solution 1
No, the way you would normally do this is overload the method like so:
public void test()
{
test("exampleText");
}
public void test(String name)
{
}
Solution 2
No, it is not. However, the following is possible:
public void test() {
test("exampleText");
}
public void test(String name) {
//logic here
}
Author by
user3455638
Updated on November 24, 2020Comments
-
user3455638 over 3 years
Is it possible to use default argument in the method with String. The code is shown below:
public void test(String name="exampleText") { }
The code above generate error. Is it possible to correct it?