Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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: 26951
83
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic