"with" 关键字(或默认方法)是否存在于 java 中?

Does the "with" keyword (or default method) exist in java?

当我注意到构造函数上的以下 "with" 关键字时,我正在编写代码,我想知道这是什么类型的构造函数(或技术),以及如何使用它。

public static Database with(String key) {
    if (sInstance == null) {
        sInstance = new Database(key);
    }
    return sInstance;
}

它的一种用法是:

mDatabase = Database.with(User.listAll(User.class).get(0).getKey());

这里的with不是关键字,它只是一个静态方法的名字。

那不是一个构造函数,它是一个静态方法,(我假设)returns class 的一个实例,它包含在其中