Please can you help me to figure out the differences between static and non-static members in interfaces?
Difference between static and non-satic members in interface.
Collapse
X
-
Thanks that's what i expected .... so one more question ..what abut static and non-static inner interface?Originally posted by JosAHOnly fields can be static in an interface (they're implicitly static, public and final). Methods
are implicitly abstract and public.
kind regards,
JosComment
-
There's a new little article in this forum; it is at the top of the threads page andOriginally posted by dmjproThanks that's what i expected .... so one more question ..what abut static and non-static inner interface?
is named "Read This First". There's a link to the Java Language Specifiction in
there; if I'm not mistaken it's chapter #9 that answers all your questions you
were too afraid to ask.
kind regards,
JosComment
-
Basically what happened Jos that yesterday i downloaded the PDF..Originally posted by JosAHThere's a new little article in this forum; it is at the top of the threads page and
is named "Read This First". There's a link to the Java Language Specifiction in
there; if I'm not mistaken it's chapter #9 that answers all your questions you
were too afraid to ask.
kind regards,
Jos
But i think it would be difficult to understand if i don't understand Mathematics, that's why i left that book . :-)Comment
-
It has nothing to do with mathematics, it's all just definitions. What (relevant)Originally posted by dmjproBasically what happened Jos that yesterday i downloaded the PDF..
But i think it would be difficult to understand if i don't understand Mathematics, that's why i left that book . :-)
section of that JLS (Java Language Specification) don't you understand?
Nested (static) interfaces are similar to nested (static) classes. btw understanding
at least a bit of math comes in handy when you want to be a programmer.
Also btw, why did you download the PDF version instead of the HTML version?
kind regards,
JosComment
-
Ahh .... Right ...actually i tried to download but ....failed ...then i went for HTML ..it come properly ....!!!Originally posted by JosAHIt has nothing to do with mathematics, it's all just definitions. What (relevant)
section of that JLS (Java Language Specification) don't you understand?
Nested (static) interfaces are similar to nested (static) classes. btw understanding
at least a bit of math comes in handy when you want to be a programmer.
Also btw, why did you download the PDF version instead of the HTML version?
kind regards,
Jos
Yeah i understand ..i m trying grip the Core Java while i doing advanced programming ..i should take advantages of Java provides .....So i am trying to dig into deeper ....as soon as the Math concerns i ll consult with you; the math expert ...lol... :-)
anyway thanks !Comment
-
Oh............. :-)Originally posted by JosAHI hope you don't mind that I don't understand you at all now.
kind regards,
Jos
Basically i move to and fro in JAVA.
But right now i got understood that before going to advance i have to grip all the basics...
I have lack of that one very much that's why i am trying to do that.
And yeah to be a programmer a bit of Mathematics knowledge should be there....:-)
I promise you that next time you will not misunderstand me....Comment
-
I agree with JosH: The JLS is the Java Bible when it comes to definitive answers. It's not mathematics, but parts of it can be difficult to read because the Java language needs to be precisely defined. (If you think it's hard to read, try reading some legal documents!)Originally posted by dmjproThanks that's what i expected .... so one more question ..what abut static and non-static inner interface?
Anyway, it's also a good exercise to write a little code to test what you have read:
[CODE=Java]import java.lang.refle ct.Modifier;
interface I {
interface J {}
class C {}
}
class D {
interface K {}
class E {}
}
public class Testing {
public static void main(String[] args) {
test(I.class);
test(I.J.class) ;
test(I.C.class) ;
test(D.class);
test(D.K.class) ;
test(D.E.class) ;
}
static void test(Class x) {
int flags = x.getModifiers( );
System.out.prin tln("class " + x.getName() + ":");
System.out.prin tln("is static = " + Modifier.isStat ic(flags));
System.out.prin tln("is public = " + Modifier.isPubl ic(flags));
System.out.prin tln();
}
}[/CODE]
Was the output what you expected?Comment
-
Thanks BigDaddyLH, Thanks a lot.
What Jos said that in interface fields are implicitly static public final and the methods are implicitly public and abstract. So the inner interfaces or classes will be static and public. But inside the class the inner interface is static. And class is as usual. So the inner interface is always static whether it is inside the class or interface. And inner interface is an instance variable that does not make sense.
Thanks Jos and Thanks BigDaddyLH.Comment
Comment