+ 5

How to know that when we have to use 'static' keyword nd when not ?!!đŸ˜đŸ˜¶

16th Nov 2018, 5:19 PM
Shreyal Jain
Shreyal Jain - avatar
2 Answers
+ 2
Static make a variable, a method reachable by all children of the parent class and without instanciate the parent class. Very usefull to create services.
16th Nov 2018, 5:28 PM
Geoffrey L
Geoffrey L - avatar
+ 1
For ex.: public class Program{ static int check(int a, int b){ return a + b; } public static void main(String[] args) { System.out.print(check(1, 99)); } } --- Static method you can call without new Object.
5th Mar 2019, 11:37 AM
M_N