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

  • Home
  • SEARCH
  • 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 6589589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:11:37+00:00 2026-05-25T17:11:37+00:00

Can anyone explain in simple terms why in the below class, when I pass

  • 0

Can anyone explain in simple terms why in the below class, when I pass in a String, Integer or UUID, only the method overload taking Object as a parameter is used?

public final class SkuHydratingConverter implements Converter<Object, Sku> {
    @Autowired
    private SkuService skuService;


    /**
     * Default implementation, that errs as we don't know how to convert from
     * the source type.
     */
    public Sku convert(Object source) throws IllegalArgumentException {
        throw new IllegalArgumentException("Could not convert to Sku");
    }


    public Sku convert(String source) throws IllegalArgumentException {
        return convert(Integer.valueOf(source));
    }


    public Sku convert(Integer source) throws IllegalArgumentException {
        return skuService.get(source);
    }


    public Sku convert(UUID source) throws IllegalArgumentException {
        return skuService.get(source);
    }
}

Originally I’d wanted to implement Converter<?, ?> three times in the one class, but I soon discovered that’s not possible.

  • 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-25T17:11:38+00:00Added an answer on May 25, 2026 at 5:11 pm

    The overloading mechanism works in compile time, that is, which method to call is decided when compiling the classes, not when you run the program.

    Since runtime types can’t (in general) be known at compile time, a snippet like this

    Object o = "some string";
    method(o);
    

    will result in a call to a method that takes an Object as argument, as Object is the compile-time type of o.

    (This has nothing to do with type-erasure or generics.)

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

Sidebar

Related Questions

Can anyone, please, explain to me in very simple terms what a "method" is
Can anyone explain in simple words what First and Second Level caching in Hibernate/NHibernate
Plain and simple, can anyone explain me how to connect to a mysql server
Can anyone explain how the FileSet includes work in hudson? Maybe with a simple
Can anyone please explain what the following two paragraphs mean, in simple english? (Taken
Can anyone explain me why on that c++ simple code valgrind returns this .
Can anyone explain how to control the XML generated ? I have a simple
Can anyone explain with a simple example the Command Pattern? I tried searching on
Can anyone explain in a simple clear way how MPEG4 works to compress data.
Can anyone explain the difference between the types mentioned above and some sample usage

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.