没有方法或静态块的Java花括号语法?

时间:2016-08-02 08:24:56

标签: java

我对Java代码块感到困惑,我不知道它代表什么。

public class Person {



    { // Here that is this ? Is this static code, apparently it is not? is it anonymous static class ?

        System.out.println(this.getClass());
        System.out.println(getAge());

    }

    private String name;
    private String age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }
}

0 个答案:

没有答案