Correct usage/method of Java Interfaces
I really don't know this is the right place to post this question,
i hope my question though fundamental, may not be that basic.
My question is: Java Interfaces, what is the proper way of using them? Conceptually, everybody i spoke to, says it supports multiple inheritance. And they just define methods, leaving upon the class that implement it, the functionality(behavior) of the methods. But although every word of this argument is true, I have also noticed that Interfaces are also used to flag. Means, certain funcationality of a particular class is only available, if a specific interfaces(s) is/are implemented. Servlets are good examples. So servlet cannot be servlet unless a particular interface is implemented.
Now the point is that, if I've to put the same behaviour in my own
program, can i do it? Or, this flagging is inbuilt inside JVM?
Can i make,
in three different packages
1) package1: Interface myInterface,
2) package2: A Class class1 with Main method,
3) package3: Another Class class2 whose functionality is available
to class1 only when interface myInterface is implemented by class1.
In such a way that when i try using class2 in class1, without
implementing myInterface, compiler gives me a message.....??
I hope i was able to explain myself. maybe i m just not thinking hard...the solution is just around the corner.
rgds to all
By umesh in forum Careers
Last Post: 08-31-2007, 03:19 PM
By Anonymous in forum Java
Last Post: 01-31-2002, 11:08 PM
By Brad O'Hearne in forum Talk to the Editors
Last Post: 11-05-2001, 09:32 AM
By Keith Franklin, MCSD in forum java.announcements
Last Post: 08-18-2000, 06:37 PM
By JJ in forum Enterprise
Last Post: 07-06-2000, 04:50 AM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL