Home / Programs / static variable (also known as class variable)
🚀 Programming Example

static variable (also known as class variable)

👁 1,029 Views
💻 Practical Program
📘 Step Learning
Learn this program step-by-step with algorithm, source code, output and detailed explanation.

💻 Program Code

 //Program of static variable
class StudentClass{

// static variable or class variable
   static String SubjectName ="Java Programming Language";

 public static void main(String args[]){

  System.out.println(SubjectName);
 }
}

/*
No need to create object in same class
If you declare any variable as static, it is known static variable.
The static variable gets memory only once in class area at the time of class loading.
It makes your program memory efficient (i.e it saves memory).
*/

                        

🖥 Program Output

Java Programming Language
Press any key to continue . . .
                            
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.