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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:27:39+00:00 2026-05-22T16:27:39+00:00

I am reading the Effective Java by Joshua Bloch and I have question about

  • 0

I am reading the Effective Java by Joshua Bloch and I have question about Item1 Static Factory Method.

Quote[Bloch, p.7]

Interfaces cant have static methods,
so by convention, static factory
methods for an interface named Type
are put in non-instantiable class
named Types. For example, the Java
Collections Framework, provide
unmodifiable collections, synchronized
collections, and the like. Nearly all
of these implementations are export
via static factory methods in one
noninstantiable class
(java.util.Collections). The classes
of the returned objects are all
non-public.

Ok. When look at the sources code, I see java.util.Collection interface and java.util.Collections class with private constructor (non-instantiable class). and I see that the non-instantiable class Collections has all static methods, just like what Bloch said. But i fail to see the connection between the two classes as Bloch said

Interfaces cant have static methods, so by convention, static factory methods for an interface named Type are put in non-instantiable class named Types.

  1. Can anyone point out the obvious to me?

  2. what is it mean when he said

The classes of the returned objects are all non-public

Here is where I obtain the java sources: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/Collection.java?av=f

  • 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-22T16:27:39+00:00Added an answer on May 22, 2026 at 4:27 pm
    1. Interfaces cant have static methods, so by convention, static factory methods for an interface named Type are put in non-instantiable class named Types.

      The point is just the plural ‘s’ on “Type[s]”. So if your interface is called Foo and you want to create some implementation called MyFoo then your factory with the methods to instantiate should be called Foos by convention.

    2. The classes of the returned objects are all non-public

      This means that the classes of objects returned from the factory methods have a private or default visibility modifier as in private class MyFoo{} so that they can not be instantiated by any other means but their factory methods. Since you can’t construct an Object using the new operator from private inner or package private class out of their scope (reflection aside).

    e.g.:

     public interface Foo{ //interface without plural 's' (question 1)
         public void bar();
     }
     public abstract class Foos(){ // abstract factory with plural 's' (question 1)
        public static Foo createFoo(){
            return new MyFoo();
        }
        private class MyFoo implements Foo{ // a non visible implementation (question 2)
           public void bar(){}
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading Joshua Bloch's Effective Java Programming Language Guide . He explains static
I am reading Effective Java by Joshua Bloch. At the top of page 16,
I was going through Effective Java and reading static factory methods for creating objects.
I'm reading Effective Java Second Edition by Joshua Bloch and im confused by below
I'm reading through Chapter 3 of Joshua Bloch's Effective Java . In Item 8:
I'm reading the Effective Java book by Joshua Bloch. In the first chapter, he
So I've been reading Effective Java by Joshua Bloch and noticed two points which
I'm currently reading Effective Java by Joshua Bloch and Item 17 is 'Design and
I am reading Effective Java. In a section that talks about using function objects
I am reading Effective Java . In the discussion about finalize, he says C++

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.