private static final

Posted on 2009-12-30
Last Modified: 2013-11-23
hi all, please tell me why to use private static final in front of variable ? If the variable is final, its value will be constant in that class. So what is the need of static keyword because if the variable is static, it has only one instance throughout the class.... Please explain.
Question by:jayz_smith
    LVL 11

    Accepted Solution

    Please have a look at this explanation:

    Java  Final vs. Static Variable

    Ask me if something is unclear and I will try to explain

    Author Comment

    @ nordtorp :  Thanks for the wonderful link. Only one question.  " Before Java can create an instance of a class, it must first load and initialize that class. One step of class initialization is assigning values to all its static fields " this is what the link says. But my question to you is, what if there is no static fields in the class ? how would that class get initialize by java ?

    Author Closing Comment

    perfect answer
    LVL 11

    Expert Comment

    It just says that one step of class initialization is assigning values to all its static fields, if there are no static fields, it does not need to assign anything.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Problem to setup 18 67
    Convert BufferedReader to File 1 49
    Basics of Drool Rule Engine with few samples 2 32
    array11 challenge 16 40
    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now