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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:43:51+00:00 2026-05-13T19:43:51+00:00

I am thinking about how much a class resides in memory in case it

  • 0

I am thinking about how much a class resides in memory in case it is not being accessed by other objects in memory?

for example suppose I have some class like this:

public class OrderNumber {
 private static long counter = 0;

 public static long getOrderNumber(){
          if (counter >= 100) {
            return counter = 1;
          }
          return ++counter;
 }
}

And I call its static method from another class:

long number = OrderNumber.getOrderNumber(); 

each time I call it, it returns an incremental number, 1, 2, 3, 4, …

So, My question is What is the probability of this method to return the initial value where it is supposed to return the sequenced value ??

  • 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-13T19:43:51+00:00Added an answer on May 13, 2026 at 7:43 pm

    Right now, the answer is forever. Class definitions are put into the permanent generation, and remain there until the program terminates.

    Note, this is a problem for dynamic languages on the JVM, like JRuby, which create classes on the fly, because these classes waste space. I believe there are changes in the works that will resolve this problem – for example, the G1 collector

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

Sidebar

Related Questions

Similar to Does TDD mean not thinking about class design? , I am having
I'm thinking about building a login system for Ruby on Rails, much like this
Without thinking about it too much, I've been doing something like the following: 1)
I was thinking about extending all my controllers from the indexController. I have in
I know that compilers have much freedom in implementing std::type_info functions' behavior. I'm thinking
I have a simple basic question about C# and inheritance. In the below example,
I've been thinking about some possible features C++ could have, does anyone know why
Thinking about avoiding code replication, I got a question that catches me every time
Thinking about if we modify the definition of Hamiltonian path as we need to
Im thinking about to use a DB for my logs instead of a normal

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.