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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:25:43+00:00 2026-05-26T21:25:43+00:00

In the official Java guide Programming with assertions it is stated that (last paragraph

  • 0

In the official Java guide “Programming with assertions” it is stated that
(last paragraph on the page)

Few programmers are aware of the fact that a class’s constructors and methods can run prior to its initialization. When this happens, it is quite likely that the class’s invariants have not yet been established, which can cause serious and subtle bugs.

What is meant by this? When does this happen? Is it something I have to care about in my daily use of 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-26T21:25:44+00:00Added an answer on May 26, 2026 at 9:25 pm

    Basically, they talk about the following situation:

    public class Foo {
        public static Foo INSTANCE = new Foo(); // Prints null
    
        public static String s = "bar";
    
        public Foo() {
            System.out.println(s);
        }
    }
    

    As you can see, in this case constructor runs before initializer of the static field s, i. e. prior to the full initialization of the class. It’s just a simple example, but it can become more complex when multiple classes are involved.

    It’s not something you can often see in your everyday work, but you need to be aware of this possibility and avoid it when writing code.

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

Sidebar

Related Questions

I do Java programming and recently started learning Python via the official documentation. I
I read from the official tutorial of Java that prefix and postfix ++ --
Consider this code from the official OpenJDK source of java.awt.font.TextLayout : public final class
Quoting, Sun's Official Java Tutorial Class names, 'HelloWorldApp', are only accepted if annotation processing
I'm looking for the official naming convention in Java regarding accessors. I've seen that,
I googled,I checked wikipedia.None of them helped me to find an official java compiler
Official guide says: Tomcat deployment is trivial and requires copying the WAR file into
The official oauth guide makes this recommendation: It is important not to try and
Does anyone know the official method for submitting feedback on C# 4.0 so that
What are the official dates when the different versions of Java (JDK 1.3, JDK

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.