Feature request

Wanderer Wanderer wand at linuxmail.org
Sun Jun 30 05:27:11 PDT 2013


Hello all.

Sorry if I'm posting this to the wrong list.

I have a feature ask for Java.

Please add support for the default values in constructor/method parameters.

Something like this:

class MyClass {
  MyClass(int param1 = 0, String param2 = "Java", boolean param3 = false) {
    ...
  }
}

So all the following usages would be valid:

new MyClass(100,"Java is cool",true);
new MyClass(100,"Java is cool");
new MyClass(100);
new MyClass();

I have downloaded the most recent version of JDK, and this example gives me a compile error. So I have to write 3 or 4 versions of the constructor with different signatures. This makes code hard to understand.

I have switched to Java after PHP, and it's very annoying that such a nice language still lacks this very efficient and useful feature.

Thanks,
W



More information about the jdk7u-dev mailing list