Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this actually in Java?

I am working in Selenium, and this question is more specific to Java rather than Selenium.

The example I am providing is Selenium WebDriver ExplicitWait,

new ExpectedCondition<WebElement>(){
        @Override
        public WebElement apply(WebDriver d) 
        {
            return d.findElement(By.id("myDynamicElement"));
        }});

What he is exactly Doing ? How he is writing Logic without Assigning a Reference to an object to the class ExpectedCondition ???

Thanks.

like image 772
Fazy Avatar asked Jan 05 '13 06:01

Fazy


1 Answers

What is happening here is the creation of an anonymous class that inherits from ExpectedCondition. In the body of this class he is then overriding the method apply(...).

like image 88
Simon Avatar answered Sep 28 '22 20:09

Simon