Please can you help me to figure out the differences between static and non-static members in interfaces?
11 1712
Only fields can be static in an interface (they're implicitly static, public and final). Methods
are implicitly abstract and public.
kind regards,
Jos
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?
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
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 . :-)
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
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 !
I hope you don't mind that I don't understand you at all now.
kind regards,
Jos
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....
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: - import java.lang.reflect.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.println("class " + x.getName() + ":");
-
System.out.println("is static = " + Modifier.isStatic(flags));
-
System.out.println("is public = " + Modifier.isPublic(flags));
-
System.out.println();
-
}
-
}
Was the output what you expected?
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.
I will read the full documents ..How Sun implements OOP in java.
Sign in to post your reply or Sign up for a free account.
Similar topics
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
|
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
|
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...
|
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() {
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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,...
|
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...
| |