• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Need to Extend two methods

 
Ranch Hand
Posts: 421
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello I need to extend two methods:

public class MyClass extends javax.swing.JFrame implements PropertyChangeListener{
public class MyClass extends lib.BasePageInline

How do I do this?

thanks,
Michele
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michele,

Can you please mention your correct requirement please?
As per my assumption, you want to ask how to extend two classes and not methods? right?

If thats the case let me tell you that it is not possible since multiple inheritance is not supported in java.
You need to make use of Interfaces for the same.

Kindly go through some java tutorials for Inheritance and Interfaces concepts it will be helpful for you.

Thanks and Regards,
---------------------------------------------------------------------------------------
Ashwini Kashyap | akashyap@infocepts.com | www.infocepts.com
---------------------------------------------------------------------------------------
 
Michele Smith
Ranch Hand
Posts: 421
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I understand what you have said, thanks for reminding me regarding the same.

However, my question could be extended to something such as Request.Dispatcher method

Do you know how to use it so that I can creatively extend the methods into the one class, thanks,

Michele
 
lowercase baba
Posts: 13082
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally, folks don't use the phrase "extend methods". You either extend a class, or you can implement or override a method. but 'extending a method' just doesn't make sense.

If you are asking "how can I extend two classes?" - you can't.

 
Ashwini Kashyap
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michele Smith wrote:
However, my question could be extended to something such as Request.Dispatcher method

Do you know how to use it so that I can creatively extend the methods into the one class, thanks,

Michele




I am trying to understand your requirement but unable to do so. Can you please form sentence in such a way that I am able to get through.
"Extending the methods" is wrong question actually hence it will be beneficial if you explain your requirement clearly may be I can help.

Thanks and Regards,
---------------------------------------------------------------------------------------
Ashwini Kashyap | akashyap@infocepts.com | www.infocepts.com
---------------------------------------------------------------------------------------
 
Michele Smith
Ranch Hand
Posts: 421
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good points. I meant extend classes.

I have a problem on this code now:



I instantiated this at the end of my existing servlet, after the instantiation of the image:



I wondered, why would the lines

System.out.println and
rd.include(request.response)

be erroring out?

Thanks,
 
Michele Smith
Ranch Hand
Posts: 421
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did this, do you think it will work?

No errors

 
Ashwini Kashyap
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michele, I think the problem is in including image with include() . I dont think it will work.
Basically, include() method of RequestDispatcher includes the content of the requested resource (any of them jsp, servlet, html, etc) on the server response.

Also as I said before you cant extend multiple classes but you can implement multiple Interfaces so proceed with that.

Thanks and Regards,
---------------------------------------------------------------------------------------
Ashwini Kashyap | akashyap@infocepts.com | www.infocepts.com
---------------------------------------------------------------------------------------
 
Ranch Hand
Posts: 334
2
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ashwini is correct multiple inheritance is not possible in Java BUT it's rarely if ever needed.

Besides using interfaces you can also use a member class. Just instantiate or pass the 2nd class and make the call from inside.

The big advantage of an interface is calling code can refer to the interface and use any class that implements it but you can't use it with library classes that are already defined.

Joe
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic