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 5994325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:48:08+00:00 2026-05-22T23:48:08+00:00

I have a generic method public <K extends Number> K get() { … }

  • 0

I have a generic method

public <K extends Number> K get()
{
    ...
}

When I call this method, I use a syntax like:

Integer i = instance.<Integer>get();

However, this is also legal:

Integer i = instance.get();

My question is, is the second method call a form of type inference in 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-22T23:48:09+00:00Added an answer on May 22, 2026 at 11:48 pm

    Yes, this is type inference based on the assignment type. It’s specified in section 15.12.2.8 of the JLS:

    If any of the method’s type arguments were not inferred from the types of the actual arguments, they are now inferred as follows.

    • If the method result occurs in a context where it will be subject to assignment conversion (§5.2) to a type S, then let R be the declared result type of the method, and let R’ = R[T1 = B(T1) … Tn = B(Tn)] where B(Ti) is the type inferred for Ti in the previous section, or Ti if no type was inferred.

    Then, a set of initial constraints consisting of:

    • the constraint S >> R’, provided R is not void; and
    • additional constraints Bi[T1 = B(T1) … Tn = B(Tn)] >> Ti, where Bi is the declared bound of Ti,

    is created and used to infer constraints on the type arguments using the algorithm of section (§15.12.2.7). Any equality constraints are resolved, and then, for each remaining constraint of the form Ti <: Uk, the argument Ti is inferred to be glb(U1, …, Uk) (§5.1.10).

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

Sidebar

Related Questions

I have a class A like this: public class A<T extends Number> { ....
I have a generic PostProcessor interface that looks like this: public interface PostProcessor<T> {
This is my scenario. I have a generic class: public class Tuple<T> extends ArrayList<T>
I have a generic method with this (dummy) code (yes I'm aware IList has
In my base class I have a generic method (ideally this would be a
I'd like a generic method for retrieving the data from a vector. I have
I have a generic Logger class that looks like this: class Logger { ...
I have a generic type that is parameterized on some Enum, declared like this:
I'd like my EqualTester generic class to call the overridden equals(...) method of its
I have two interfaces which are generic, IComparable<T> , with method public boolean gt(T

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.