0

What is 'static'? What does it mean and what is it used for?

3rd Nov 2016, 3:50 PM
Tupperrwuz
Tupperrwuz - avatar
2 Réponses
+ 2
If you want a bunch of utility functions available throughout you app declare them as static methods in a class and you can use them whenever and wherever without having to instantiate an object of that class. Just like you use Math.sqrt as Aditya pointed out.
3rd Nov 2016, 10:59 PM
Eduard Alexandru
Eduard Alexandru - avatar
0
static variables and function are access without using object of class, like Math.sqrt sqrt is static in Math class. Without static is like Scanner s = new Scanner(System.in); here you have to create object on Scanner to use s.nextLine(); function, coz nextLine() is not static.
3rd Nov 2016, 4:00 PM
Aditya kumar pandey
Aditya kumar pandey - avatar