Skip to main content

What is static in Java?

static is a non-access modifier in Java which is used mainly for the purpose of memory management. static belongs to the class instead of the instance of the class. static keyword can be used with:

1. Variables
2. Methods
3. Nested Classes
4. Blocks

In order to create a static member, we need to write the keyword static preceding the declaration of the member.

Static Variables

If a variable is declared as static:
  • It will get memory only once in the class area at the time of class loading.
  • The single copy of this variable will be shared among all the instances of the class.
Example of the static variable


Output: 
10
20

Comments

  1. King Casino Login | All your games online and - Community Khabar
    Login King gri-go.com Casino, novcasino Play, and 바카라 사이트 Win! Login King Casino, Play. Login King Casino, Play. Login King Casino, Play. Login King Casino, Play. communitykhabar Login King https://sol.edu.kg/ Casino, Play. Login King Casino,

    ReplyDelete

Post a Comment

Popular posts from this blog

Introduction to Selenium WebDriver

First, let me try to explain what Selenium is. So, if you go by the official definition, Selenium automates browsers  that's it. It is a set of tools to automate browsers on many platforms. WebDriver is among this set of tools along with IDE, RC (Remote Control) and Grid. We'll talk only about Selenium WebDriver in this post. What is Selenium WebDriver and what does it do? Selenium WebDriver is a test automation framework which is used to automate the tests on different browsers. WebDriver controls the browsers by directly communicating with them. Selenium WebDriver is very powerful and this power can be best utilized by using a programming language to write the tests. Writing tests using a programming language is also known as scripting and there are many programming languages which can be used with Selenium WebDriver for the purpose of scripting. Here's the list of the programming languages supported by Selenium WebDriver: Java Python C# PHP Perl Ruby Out ...