EducationBlog

banner image

Home - PageNavi (show/hide)

banner image

Differences between static and non static variables in java.

The main differences between static and non static variables are:
STATIC VARIABLENON STATIC VARIABLE
Static variables can be accessed using class nameNon static variables can be accessed using instance of a class
Static variables can be accessed by static and non static methodsNon static variables cannot be accessed inside a static method.
Static variables reduce the amount of memory used by a program.Non static variables do not reduce the amount of memory used by a program
Static variables are shared among all instances of a class.Non static variables are specific to that instance of a class.
Static variable is like a global variable and is available to all methods.Non static variable is like a local variable and they can be accessed through only instance of a class.
Differences between static and non static variables in java. Differences between static and non static variables in java. Reviewed by Pappy on September 03, 2019 Rating: 5

No comments:

Sports

3/Sports/small-col-right
Powered by Blogger.