PDA

View Full Version : static variable In Java ?



Joyadelfin
09-27-2019, 05:27 AM
Hello Dear,

Please Tell Me What is the static variable In Java ?

trinityy
10-17-2019, 12:33 PM
Hello, static variables are declared with the static keyword in a class, but outside a method, constructor or a block. It is also known as Class variables. It reduces the memory footprint of the program.

Thanks!

javascript library (https://www.twik.io/resources/variants/)

sevencreations
11-13-2019, 01:20 AM
There are three types of variables in Java:

Local variable
Instance variable
Static variable

RuskinF
05-11-2020, 07:21 AM
Here have it.
The static variable in Java is variable which belongs to the class and initialized only once at the start of the execution. It is a variable that belongs to the class and not to object(instance ). Static variables are initialized only once, at the start of the execution.

I hope it helps!
Regards.

RH-Calvin
05-14-2020, 08:04 AM
Static variable in Java is variable which belongs to the class and initialized only once at the start of the execution. It is a variable which belongs to the class and not to object(instance ). Static variables are initialized only once, at the start of the execution.

charlesprabhu
03-18-2021, 10:21 PM
A static int variable remains in memory while the program is running. A normal or auto variable is destroyed when a function call where the variable was declared is over.