M
MRe
Hi,
Two example programs below, I'm wondering if someone could tell me
why example 1 doesn't work, given that example 2 does? The error says
that a nested class has protected access, but I am accessing it from
an inheriting class
Thank you,
Kind regards,
Eliott
/////////////////////////////////////////////////////////////////////
// Example 1
/////////////////////////////////////////////////////////////////////
// test/A.java
package test;
import test.A.NA;
public class A<T extends NA>
{
protected static class NA
{
}
}
// test/extend/B.java
package test.extend;
import test.A;
import test.extend.B.NB;
public class B
extends A<NB>
{
// ERROR : test.A.NA has protected access in nestedtest.A
protected static class NB
extends A.NA
{
}
}
/////////////////////////////////////////////////////////////////////
// Example 2
/////////////////////////////////////////////////////////////////////
// test/A.java
package test;
public class A<T>
{
protected static class NA
{
}
}
// test/extend/B.java
package test.extend;
import test.A;
public class B
extends A<Void>
{
// No error
protected static class NB
extends A.NA
{
}
}
Two example programs below, I'm wondering if someone could tell me
why example 1 doesn't work, given that example 2 does? The error says
that a nested class has protected access, but I am accessing it from
an inheriting class
Thank you,
Kind regards,
Eliott
/////////////////////////////////////////////////////////////////////
// Example 1
/////////////////////////////////////////////////////////////////////
// test/A.java
package test;
import test.A.NA;
public class A<T extends NA>
{
protected static class NA
{
}
}
// test/extend/B.java
package test.extend;
import test.A;
import test.extend.B.NB;
public class B
extends A<NB>
{
// ERROR : test.A.NA has protected access in nestedtest.A
protected static class NB
extends A.NA
{
}
}
/////////////////////////////////////////////////////////////////////
// Example 2
/////////////////////////////////////////////////////////////////////
// test/A.java
package test;
public class A<T>
{
protected static class NA
{
}
}
// test/extend/B.java
package test.extend;
import test.A;
public class B
extends A<Void>
{
// No error
protected static class NB
extends A.NA
{
}
}