473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Difference between static and non-satic members in interface.

dmjpro
2,476 2GB
Please can you help me to figure out the differences between static and non-static members in interfaces?
Aug 16 '08 #1
11 1712
JosAH
11,448 Expert 8TB
Only fields can be static in an interface (they're implicitly static, public and final). Methods
are implicitly abstract and public.

kind regards,

Jos
Aug 16 '08 #2
dmjpro
2,476 2GB
Only fields can be static in an interface (they're implicitly static, public and final). Methods
are implicitly abstract and public.

kind regards,

Jos
Thanks that's what i expected .... so one more question ..what abut static and non-static inner interface?
Aug 16 '08 #3
JosAH
11,448 Expert 8TB
Thanks that's what i expected .... so one more question ..what abut static and non-static inner interface?
There'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
Aug 16 '08 #4
dmjpro
2,476 2GB
There'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
Basically 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 . :-)
Aug 16 '08 #5
JosAH
11,448 Expert 8TB
Basically 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 . :-)
It 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
Aug 16 '08 #6
dmjpro
2,476 2GB
It 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
Ahh .... Right ...actually i tried to download but ....failed ...then i went for HTML ..it come properly ....!!!
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 !
Aug 16 '08 #7
JosAH
11,448 Expert 8TB
I hope you don't mind that I don't understand you at all now.

kind regards,

Jos
Aug 16 '08 #8
dmjpro
2,476 2GB
I hope you don't mind that I don't understand you at all now.

kind regards,

Jos
Oh.............:-)
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....
Aug 16 '08 #9
BigDaddyLH
1,216 Expert 1GB
Thanks that's what i expected .... so one more question ..what abut static and non-static inner interface?
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!)

Anyway, it's also a good exercise to write a little code to test what you have read:

Expand|Select|Wrap|Line Numbers
  1. import java.lang.reflect.Modifier;
  2.  
  3. interface I {
  4.     interface J {}
  5.     class C {}
  6. }
  7.  
  8. class D {
  9.     interface K {}
  10.     class E {}
  11. }
  12.  
  13. public class Testing {
  14.     public static void main(String[] args) {
  15.         test(I.class);
  16.         test(I.J.class);
  17.         test(I.C.class);
  18.         test(D.class);
  19.         test(D.K.class);
  20.         test(D.E.class);
  21.     }
  22.  
  23.     static void test(Class x) {
  24.         int flags = x.getModifiers();
  25.         System.out.println("class " + x.getName() + ":");
  26.         System.out.println("is static = " + Modifier.isStatic(flags));
  27.         System.out.println("is public = " + Modifier.isPublic(flags));
  28.         System.out.println();
  29.     }
  30. }
Was the output what you expected?
Aug 18 '08 #10
dmjpro
2,476 2GB
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.
Aug 19 '08 #11
dmjpro
2,476 2GB
I will read the full documents ..How Sun implements OOP in java.
Aug 19 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: prabhu | last post by:
hello to all, Please can anybody tell me the differnece between static and ordinary member variables. thankyou in advance, vishnu
3
by: Der Andere | last post by:
Do non-member static functions exist? If yes, what is the sense of making a non-member function a static function? Can these functions only access static variables? Cheers, Matthias Treder
22
by: Steve - DND | last post by:
We're currently doing some tests to determine the performance of static vs non-static functions, and we're coming up with some odd(in our opinion) results. We used a very simple setup. One class...
5
by: Ren? Paw Christensen | last post by:
Hi. Considering the following code, I want this call: Something.Method(); To return "Something". public class BaseClass { public static string Method() {
9
by: tkrogc | last post by:
I compiled the source below using the comeau compiler http://www.comeaucomputing.com/tryitout/ Why does the f funtion compile while the g function produces an lvalue error ? (I thought the two...
8
by: nytimescnn | last post by:
I've read some discuession about lock() for thread-safe. I am wondering what will be the differce between below two code segment? Code 1: class A { private static Object padlock = new...
23
by: Jess | last post by:
Hello, I understand the default-initialization happens if we don't initialize an object explicitly. I think for an object of a class type, the value is determined by the constructor, and for...
17
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
What is the difference of == and Object.Equals() If I want to query werther to pointers are pointing to same instance, do I use == or Objects.Equals? foo a,b; if ( a == b ) ... or if...
1
by: JavaJon | last post by:
The problem in the follow code occurs when trying to instantiate an array object. public class Main { /** * @param args the command line arguments */ public static void...
11
by: cmb3587 | last post by:
I have two arrays and I'm trying to create a 3rd array that is the difference between the two arrays Ex: arrayA: 3 5 8 9 arrayB: 3 4 6 9 difference of A-B: 5 8 however, my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.