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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:38:43+00:00 2026-06-08T13:38:43+00:00

A static / class variable is defined in a type / class and is

  • 0

A static / class variable is defined in a type / class and is said to associate with the type / class that it is defined in and is independent of an instances of the type / class. There is exactly one static / class variable in the type / class and is best used for constant like properties, whose value would be common amongst any instances of the class. The state of a static / class variable is always exists in the class and therefore there is only one variable at any moment in the class and the keyword static is used to define this nature of the variable. The static / class variable in best practice is to be initialized once and this is ensured using the keyword final. A final static variable is to be initialized with an immutable collection as in a new String() or new Integer();

Now my question is how is the value from the static variable used?
And what is the use of this variable called? E.g does it copy it’s value from the class that it is contained in or is it an explicit reference to the variable in the class?

e.g

class GenericType {
    private final static String commonValue = new String("foobar");
} 
class AnotherGenericType {
    public static void main(String[] args) {
        System.out.println(GenericType.commonValue); //Displays foobar in the console.

    }
}
  • 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-08T13:38:45+00:00Added an answer on June 8, 2026 at 1:38 pm

    There is space specifically allocated for the storage of static variables. This is specified in the JLS, 8.3.1.1, which states

    If a field is declared static, there exists exactly one incarnation
    of the field, no matter how many instances (possibly zero) of the
    class may eventually be created. A static field, sometimes called a
    class variable, is incarnated when the class is initialized.

    It’s worth noting that these variables aren’t open for garbage collected until the class is unloaded (which doesn’t usually happen often), which is a potential for unintended memory references being held.

    Accessing static members could possibly be referred to as ‘static access’ (I’ve heard it used before) but generally it doesn’t have its own term.

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

Sidebar

Related Questions

I am having a problem accessing a static const variable defined in my class
If you have a template class with a static variable, is there any way
I have a class with a static std::map member variable that maps char s
It seems to me that a static class variable is identical to an extern
I want to initialize a static Class variable in Java: public class NumberExpression {
This has defeated me. I want to have a static class variable which is
class a { int variable;//4 bytes } class a { static int variable;//? bytes
I have a class with static method which has a local static variable. I
I have a static variable partner in the class. And I want to set
How can I access a static variable in a separate class in PHP? Is

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.