[英]How to create the object of class where constructor is parameterized constructor using default access modifier
I am working enhancement project.我正在工作增强项目。
Here they created some classes using parameterized constructor using default
access modifier.在这里,他们使用default
访问修饰符使用参数化构造函数创建了一些类。 I want to create those classes object and use the methods for call business functionalities.我想创建这些类对象并使用调用业务功能的方法。 packages are different.包不一样。
public class CheckAmount {
private double balance;
CheckAmount(double balance){
this.balance = balance;
}
.....
}
so how to create the object of classes.那么如何创建类的对象。 Please provide different approches.. if possible.如果可能,请提供不同的方法。 Thanks谢谢
Default access means that access is allowed within same package.默认访问意味着在同一包内允许访问。 So you need the public
modifier.所以你需要public
修饰符。 Another possibility is to introduce an indirection like a factory and dependency injection, but this is more advanced.另一种可能性是引入像工厂和依赖注入这样的间接方式,但这是更高级的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.