更新时间:2023-11-13 14:02:34
您可以使用工厂对象代替。然后可以运行检查并返回实例化的对象,或者返回null。这可能比例外更为有效。
You could use a factory object instead. This could then run your checks and return the instansiated object, or null. This would probably be more efficient than an exception.
MyObject myObject = MyObjectFactory.createMyObject();