?
-
If a superclass is static and its subclass isn't, will the subclass be
static?
public static class A {
}
public class A1 extends A {
}
static?
public static class A {
}
public class A1 extends A {
}
- - said:If a superclass is static and its subclass isn't, will the subclass be
static?
public static class A {
}
public class A1 extends A {
}
- said:If a superclass is static and its subclass isn't, will the subclass be
static?
public static class A {
}
Chris said:-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
According to:
http://www.javaworld.com/javaworld/javaqa/1999-08/01-qa-static2.html
...
"You declare a top-level class at the top level as a member of a
package. Each top-level class corresponds to its own java file sporting
the same name as the class name.
A top-level class is by definition already top-level, so there is no
point in declaring it static; it is an error to do so. The compiler will
detect and report this error."
It doesn't make any sense to declare a top-level class as static,
because it's implicitly static. There is no outer class for it to carry
a "this" reference to.
Chris
- said:My mistake. I forgot to mention that class A and A1 are nested classes.
So will A1 inherit A's static?
My mistake. I forgot to mention that class A and A1 are nested classes.
So will A1 inherit A's static?
- said:My mistake. I forgot to mention that class A and A1 are nested classes.
So will A1 inherit A's static?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.