Static Methods Part 2 Tutorial

In this tutorial, I will use a mix and match of static and non-static methods to complete the results of the all-important coin flipping study.
Here is a quick refresher from my Introduction to the Static Modifier tutorial.
Suppose we just won a multi-million dollar grant for a really important government study to determine if a there really is a 50/50 chance that a coin will land on either heads or tails.
The specs for the grant require a minimum of 1,000,000 flips of a coin to be performed.
The best approach will be to hire a bunch of people to flip coins and press either a heads button or tails button depending on the result of the flip.
We'll need a high-tech workstation (table, chair, coin, heads button, tails button) for every worker that will connect to a central computer that will tally two competing values – heads and tails.

Open the command prompt (CMD - see the Getting Started ) and type in the following commands.

Now switch back to the command prompt (CMD) and type in javac ImportantStudy.java and press Enter.
Now type in java ImportantStudy and press Enter.

C:\Java\ImportantStudy>javac ImportantStudy.java
C:\Java\ImportantStudy>java ImportantStudy // run this a few times for different results
Drumroll ... and our results are:
Heads total: 499972
Tails total: 500028
I'm calling it close enough for government work, let's grab a bite to eat..

Final thoughts

Learning how to make calls between static and non-static methods is a skill that will come in quite handy.
Understanding that that there is exactly one copy of a class variable is critical, especially when you consider that a class variable can be accessed by a reference to the class it resides in.
The static keyword applied to a variable is the only difference in syntax between an instance variable and a class variable.