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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:29:53+00:00 2026-05-15T17:29:53+00:00

Is calling Class.getInstance() equivalent to new Class() ? I know the constructor is called

  • 0

Is calling Class.getInstance() equivalent to new Class()?
I know the constructor is called for the latter, but what about getInstance()?
Thanks.

  • 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-15T17:29:54+00:00Added an answer on May 15, 2026 at 5:29 pm

    There is no such method as Class#getInstance(). You’re probably confusing it with Class#newInstance(). And yes, this does exactly the same as new on the default constructor. Here’s an extract of its Javadoc:

    Creates a new instance of the class represented by this Class object. The class is instantiated as if by a new expression with an empty argument list. The class is initialized if it has not already been initialized.

    In code,

    Object instance = Object.class.newInstance();
    

    is the same as

    Object instance = new Object();
    

    The Class#newInstance() call actually follows the Factory Method pattern.


    Update: seeing the other answers, I realize that there’s some ambiguity in your question. Well, places where a method actually named getInstance() is been used often denotes an Abstract Factory pattern. It will "under the hoods" use new or Class#newInstance() to create and return the instance of interest. It’s just to hide all the details about the concrete implementations which you may not need to know about.

    Further you also see this methodname often in some (mostly homegrown) implementations of the Singleton pattern.

    See also:

    • Real world examples of GoF design patterns.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 532k
  • Answers 531k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In Perl: $string =~ s/([\w']+)/\u\L$1/g; (taken from the Perl FAQ) May 17, 2026 at 12:02 am
  • Editorial Team
    Editorial Team added an answer FiddlerCore does not currently offer the ability to customize the… May 17, 2026 at 12:02 am
  • Editorial Team
    Editorial Team added an answer Since this question was asked, Facebook has added a new… May 17, 2026 at 12:02 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

StyleCop has a rule about using this. prefix to calling class members (SA1101). Is
does anyone know a way to call a generic method of a base class
I'm calling the twitter4j library using Clojure like so: (def twitter (. (TwitterFactory.) getInstance))
Im having a problem with using a variable as the class name when calling
I have a random question about const correctness. Lets say i have a class
My views extend a base view class I've made: public class BaseView : ViewPage
I'm trying to understand what the Java java.security.Signature class does. If I compute an
I am working on gps based application. I am using LocationProvider and calling setlocationListener
When my code is calling a certain function, I'm getting an error: H:\workspace\HW5\HW5\Manager.obj Error
I have a class Session.cs in the App_Code directory that needs to extract some

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.