• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

interface

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi everyone,
There are many interfaces in jave. For example consider
public interface RequestDispatcher. In this interface, there are 2 methods by name include() and forward(). We know that both the methods do some work when they are called. But seeing the interface, they look empty. Somewhere the implementation would have written. How to find , where the implementation has written? Please suggest me here.
cheers.
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interfaces does not include any implementation. You are forced to provide your own implementation in your class when implementing the interface.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the example you've given, RequestDispatcher will be implemented by web containers applying to the official Servlet Specification. So if you want to check the content of its implementation, you'll have to dig into the container's source.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hii Bobz , yes you are thinking in rigth way ,there is implementation for each method in RequestDispathcher interface but it is in RequestDispathcherImpl.class; which you can find on your server lib directory.
 
bobz
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok TY. Suppose if we write our own interface with some methods inside it, where we have to actually implement them.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you write an interface called MyInterface you can then implement it in one or more classes. The compiler will then require you to either implement the methods in MyInterface, or change your class to be abstract.

Does that make sense so far? If so, I hope you're ready to ask why we do this kind of thing.
 
Sheriff
Posts: 28365
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"bobz", welcome to the JavaRanch.

We're a friendly group here, but we do require members to have valid display names.

Display names must be your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.
 
Trust God, but always tether your camel... to this tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic