my doubt is that right after his constructor, he has a ; which shouldn't be there.
While it doesn't seem to be generally used, it is valid syntax.
As I implied by my previous post there's nothing wrong with it since it compiles perfectly.
You could argue that it might be a bug in the compiler, but I will support my statement by quoting the relevant section(s) of the Java Language Specification:
ClassMemberDeclaration:
FieldDeclaration
MethodDeclaration
ClassDeclaration
InterfaceDeclaration
; // semicolon is a valid ClassMemberDeclaration
(Source: JLS - 8.1.6 Class Body and Member Declarations)
Therefore you could write syntactically valid code like:
public class Test
{
private int a;
public Test(int a)
{
this.a = a;
};; // [1]
public int getA()
{
return a;
}; // [1]
public static void main(String[] args)
{
System.out.println(new Test(15).getA());
;;;;;; // [2]
}; // [1]
}; // [3]
; // [3]
; // [3]
; // [3]
;;;; ;; // [3]
class B
{
}
Lines marked by a [1] are valid as of: JLS - 8.1.6 Class Body and Member Declarations)
ClassMemberDeclaration:
FieldDeclaration
MethodDeclaration
ClassDeclaration
InterfaceDeclaration
;
Lines marked by a [2] are valid as of: JLS - 14.6 The Empty Statement
EmptyStatement:
;
Lines marked by a [3] are valid as of: JLS - 7.6 Top Level Type Declarations
TypeDeclaration:
ClassDeclaration
InterfaceDeclaration
;