---
title: "What are local static variables? and How to use them?"  
description: "What are local static variables? and How to use them?"  
author: "Paul Wilson"  
published: 2017-11-13  
canonical: https://answers.mindstick.com/qa/30449/what-are-local-static-variables-and-how-to-use-them  
category: "programming"  
tags: ["variables"]  
reading_time: 1 minute  

---

# What are local static variables? and How to use them?

What are [local](https://www.mindstick.com/forum/546/how-to-create-local-user-in-windows-8) [static](https://www.mindstick.com/articles/12098/the-static-keyword-the-static-methods) [variables](https://www.mindstick.com/articles/715/php-variables)? and How to use them?\

## Answers

### Answer by Arti Mishra

**“Static Variable”** Static variables are those variable which is **created with the help of static keyword** in a class and it is also called class variable. **It creates a single copy in the RAM** and **each object can share it**. Static variable **directly accesses by the help of class name** without using any objects.\
**How to Use it** **Syntax :** ClassName.VariableName; \
**For Example**class Test\
{ static int x=100; Test() { System.out.println(“Test Class Call...”); } } class Main { public static void main(String args[]) { Test obj=new Test();System.out.println(“Value of Static Variable : “+ Test.x); } } \


---

Original Source: https://answers.mindstick.com/qa/30449/what-are-local-static-variables-and-how-to-use-them

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
