Take the following:
if (filter instanceof FileNameExtensionFilter) {
fnef = (FileNameExtensionFilter) filter;
String[] extensions = fnef.getExtensions();
if (extensions.length > 1) {
fnef = filter = new FileNameExtensionFilter(fnef.getDescription(), extensions[0]);
}
}
where filter is a FileFilter object and fnef an instance variable of the type FileNameExtensionFilter.
Would you consider it good coding practice to assign a value to multiple variables on the same line? Or would it be better to write line 6 from the example as follows:
fnef = new FileNameExtensionFilter(fnef.getDescription(), extensions[0]);
filter = fnef;
I personally prefer the latter, though I’d like to hear what you think.
This is a pretty subjective question.
I think this is more clear:
But any experienced developer will understand this: