简体   繁体   中英

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. 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. Another possibility is to introduce an indirection like a factory and dependency injection, but this is more advanced.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM