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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:46:40+00:00 2026-06-11T01:46:40+00:00

I recently came upon an instance of the following pattern: public interface IFooFactory {

  • 0

I recently came upon an instance of the following pattern:

public interface IFooFactory {
    <K> Foo<K> create();
}

See here for a concrete example. I don’t see what a client programmer is supposed to do in the implementation of create other than instantiate Foo with a formal type parameter of Object or with no formal type parameter at all. I also don’t see what’s the benefit or type constraint that the framework designer tried to express by defining the interface IFooFactory in this way.

  • 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-06-11T01:46:41+00:00Added an answer on June 11, 2026 at 1:46 am

    Consider Collections.emptyList(). The list object returned is always the same: since the list is empty and immutable, there is nothing the caller can do with the object returned in order to make it show different behaviour depending on the concrete type substituted for the type parameter. So, a single implementation (with raw types) suffices:

    public static <T> List<T> emptyList() {
        return THEEMPTYLIST;
    }
    
    public static final List THEEMPTYLIST = new List() {
        public int size() { return 0; }
        ...
    };
    

    The emptyList method makes this more convenient for the caller, though, since it enables type inference:

    List<String> noStrings = Collections.EMPTY;  // Gives compiler warning due to use of raw types
    List<String> noStrings2 = Collections.emptyList(); // No compiler warning, type parameter inferred.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently came upon a static method declared as: public class Foo { public
The company recently came upon the need to create a side by side record
I recently came upon a Microsoft article that touted new defensive enhancements of Windows
I recently came across the following piece of code. It doesn't look valid because
I recently came across this article , discussing how to leverage mod_cluster to create
I recently came upon the need to have compile-time assertions in C++ to check
I recently came across the following line of code: var type = (typeof x).toLowerCase();
I recently came upon a site that has done exactly what I want as
I was recently looking at some vp8 sample decoder code when I came upon
I recently came across fancy box located here , I've followed every step in

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.