0

I want to execute the code present in constructor before object initialization. Since object is initialize with some parameter, so the parameter carry it's values.

Calling function :

ABC as = new ABC (driver );

After Object initialization from calling function. "driver " value is passed to ABC constructor. But instead of executing code inside constructor ie this.driver= driver; . It jumps to initialized object of XYZ class . Due to which parameter of XYZ class has null value ie driver=null

public class ABC {
    public static WebDriver driver;

    public ABC(WebDriver driver) {
        this.driver = driver;
        System.out.println("**********");
    }

    XYZ st = new XYZ(driver);
}
ernest_k
  • 44,416
  • 5
  • 53
  • 99
Rama
  • 815
  • 2
  • 17
  • 37

0 Answers0