Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6630855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:27:58+00:00 2026-05-25T22:27:58+00:00

I have a class which is implementing an interface, and one of the methods

  • 0

I have a class which is implementing an interface, and one of the methods is called onClick. Is there a way to implement the onClick that the interface wants but name it something else? Something like (and I’m making this up):

public void AnyMethodNameIWant() implements Interface1.onClick

Three reasons I’m asking are:

  1. It would be nice to look at an method signature and know that it’s
    coming from an interface
  2. To avoid ‘generic’ names like onClick that an interface may require me to have
  3. To distinguish between the same method names in many interfaces

Apologies if this is a fundamentally ‘bad’ question as I am new to Java.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:27:58+00:00Added an answer on May 25, 2026 at 10:27 pm

    No, you can’t. Interfaces have to be implemented by a method of the same name in Java.

    You can use the @Override annotation with interface implementations (as of Java 6) though, which helps to clarify that this is a method which can’t just be renamed arbitrarily.

    One option for your second issue might be to create an implementation class just for the purpose of forwarding on the call to a more specific method. You might want to do this as a nested or even anonymous class. I’m not sure I’d usually do this though.

    EDIT: Having seen the third question – no, if you have two interfaces with the same method signature in Java, you can only provide one implementation 🙁 Oh, and if you’ve got two interfaces with the same signature but different return types, it’s even worse. You could always write a method of Interface1 getInterface1() which returns an instance of an anonymous inner class proxying the Interface1 methods onto the “main” class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below I have a Person interface, an implementing class and a driver class which
I am implementing the Map<V,K> and the Collection<V> interface in one class, but the
I have a generic class DirectorySource<T> which depends on an interface IDirectorySearch<T> . Both
in my Silverlight 4 project, I have a simple class implementing the interface like:
I have an Interface and two Classes which are implementing the Interface. public interface
I don't know how interface works for my problem but I have read that
I have a bunch of COM objects which all implement the same interface, and
Lets say I have a class, which implements a generic interface public interface IItem
I have a class which I'm serialising to send over a unix socket and
I have a class which implements UserControl. In .NET 2005, a Dispose method is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.