Difference between static methods, static variables, and static classes in java.
Hello Everyone????
Difference between static methods, static variables, and static classes in java.
Static Methods and Static variables?are those methods and variables that belong to the class of the java program, not to the object of the class. This gets memory where the class is loaded. And these can directly be called with the help of class names.
For example - We have used mathematical functions in the java program like - max(), min(), sqrt(), pow(), etc. And if we notice that, then we will find that we call it directly with the class name. Like - Math.max(), Math.min(), etc. So that is a static method.?And Similarly static variables we have used like (length) for the array to get the length. So that is the static method.
Static classes?- A class in the java program cannot be static except if it is the inner class. If it is an inner static class, then it exactly works like other static members of the class
#Java #Java23 #software #developer #programming #code #inheritance #class #object #static #method #variable #exceptions #collections #try #catch #throw #finally #lambda #functional #overloading #overriding #interview #OOPS #JVM #JIT #loops