Getting Started with Java
This is a 100% free course, but we need you to first join or login to watch this video.
Alright, join or login here.This video introduces you to the static keyword in Java. The static keyword can be used with variables, blocks, methods, imports and nested classes. The static variable is a class variable whereas normal variables are instance variables. Use classname.variablename to access static variables whereas classname.methodname should do the job for static methods. Static blocks can be used to initialize static variables and they are executed before the constructor. Static methods can access and modify static variables. The main method is static in Java because JVM needs to call the main method without creating an object of your class.