What is the difference between static int and simple int???? | SoloLearn: Learn to code for FREE!

0

What is the difference between static int and simple int????

its related to C,C++and Java

12/6/2017 4:55:47 PM

TIRTHARAJ SEN

1 Answer

New Answer

0

A static variable is a variable that is allocated at the start of the compilation process and thus cannot be initialized multiple times. unlike non static Data types, static types hold their values as well as their memory address throughout multiple objects of a class. In short, if you have an "Int x;" you can have multiple numbers of X. One for each object and with different values. But if you initialize a "static int x;", there will be only a single X, with the value of X being shared between objects. they are mostly used when a single copy of a data is enough, usually with the "Final" keyword.