Hi ... When attempting a
test in
http://www.danchisholm.net/july21/mybook/chapter10/exam1.html came across NESTED INTERFACES ... Below is the example as to how can nested interfaces be coded and compiled without errors ...
===
class Interface1
{
//nested interface
interface i
{
public void m1();
}
class hehe implements i
{
public void m1() { }
};
};
//interface i not visible outside the class Interface1
// needs Interface1.i to be mentioned to compile
class Try1 implements Interface1.i
{
public void m1() { }
};
interface i1
{
public void m2();
//nested interface
interface i2
{
public void m3();
}
}
//to implement inner interface i1.i2 has to mentioned
class Try2 implements i1,i1.i2
{
public void m2() { }
public void m3() { }
};
===
But I am not able to figure out a real world example as to where will it be useful. Can anyone throw light on the same. The reason why I posted this query in
SCJP forum is that, ppl should know that nested interfaces are possible and should not be bowled out in exam. Any help would be appreciated. Thanks!
(Real Time in title changed to Real World)
[ October 26, 2004: Message edited by: Barry Gaunt ]