Tuesday 31 October 2017

java - Constructors with default values of parameters

No it doesn't. Java doesn't support default arguments in
any function; constructors
included.


What you can do though is
define public Shape(int v, int e) and also a default
constructor


public
Shape()
{
this(1,
2);
}

Note the special
syntax here to delegate the construction to the two-argument
constructor.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...