I was looking at one of the nio demonstration examples and noticed this line:
// Charset and decoder for ISO-8859-15
private static Charset charset = Charset.forName("ISO-8859-15");
private static CharsetDecoder decoder = charset.newDecoder();
The first one is moderatly understandable since the method won’t create a new object. But the second line is it really necessary ?
What would be the problem if they simply use this:
private static CharsetDecoder decoder = new CharsetDecoder(charset);
Off topic: Don’t you wish sometimes you could use C++ syntax like this?
private static CharsetDecoder decoder(charset);