1 Replies - 161 Views - Last Post: 21 May 2019 - 07:07 AM Rate Topic: -----

#1 vinodkumarkotha   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-May 19

How to return nested interface methods?

Posted 21 May 2019 - 07:00 AM

I just wanted to return nested-interface methods by using a window() method which has a return type as an option. How to return such methods?


package interfaces;

interface WebDriver{
interface options{
void timeouts();
void window();
}
options manage();
}
class FirefoxDriver implements WebDriver,WebDriver.options{
@Override
public void timeouts() {
System.out.println("Ok");
}
@Override
public void window() {
System.out.println("No");
}
@Override
public options manage() {
return //how to returnd options inside options interface
}
}
public class Test{

public static void main(String[] args) {
WebDriver driver=new FirefoxDriver();
driver.manage().timeout();
}

}



it's manage() method

Is This A Good Question/Topic? 0
  • +

Replies To: How to return nested interface methods?

#2 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3638
  • View blog
  • Posts: 16,706
  • Joined: 20-September 08

Re: How to return nested interface methods?

Posted 21 May 2019 - 07:07 AM

If method manage() returns interface of type options (that should start with a capital letter) then the class that encloses that interface should create an instance of a class that implements that interface. It's that instance that will be returned to the caller

This post has been edited by g00se: 21 May 2019 - 07:07 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1