这样做的目的是什么(); 在这种背景下

use*_*491 0 java

请考虑以下代码:

    public Fingerprint(HashMap<String, Integer> measurements) {
        this();
        mMeasurements = measurements;
    }

   public Fingerprint(HashMap<String, Integer> measurements, String map) {
        this(measurements);
        mMap = map;
    }

    public Fingerprint(int id, String map, PointF location) {
        this();
        mLocation = location;
    }

    public Fingerprint(int id, String map, PointF location, HashMap<String, Integer> measurements) {
        this(id, map, location);
        mMeasurements = measurements;
    }
Run Code Online (Sandbox Code Playgroud)

这样做的目的是什么(); 在这种背景下?因为我认为"this"指的是当前对象的字段.这是相同的定义吗?

rge*_*man 6

调用this();它就好像是一个方法是从构造函数中调用另一个构造函数的方法.你有效地打电话Fingerprint().

请参阅有关该主题Java教程,"使用它与构造函数"部分.