I have a situation where i have to pass a value to a constructor from a class and i also have to call the constructor from another class but while calling the constructor from the second class i can not pass the value to its constructor.How i can achieve this ? I am trying to define the value in its default constructor , but while i am calling the constructor i need to pass the value which i want to avoid. This is my current scenario
// I have to pass the value here
DNQLtrDataAccessor data = new DNQLtrDataAccessor(aValue);
This is the corresponding class:
public class DNQLtrDataAccessor {
private static final Logger LOGGER = Logger.getLogger(DNQLtrDataAccessor.class);
String val;
public DNQLtrDataAccessor(String val) {
this.val = val;
}
And here is the other class where I don't want to provide a value:
public class UWCompanyInfo {
public void loadData(Document document, Connection connection) throws Exception {
//Here i can not pass the value
DNQLtrDataAccessor dataAccessor = new DNQLtrDataAccessor();