1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
/* Java static method example This Java Example shows how to declare and use static methods inside a java class. */ public class StaticMethodExample { public static void main(String[] args) { int result = MathUtility.add(1, 2); System.out.println("(1+2) is : " + result); } } class MathUtility{ /* * To declare static method use static keyword. * Static methods are class level methods and can not access any instance * member directly. However, it can access members of a particular object * using its reference. * * Static methods are generally written as a utility method or it performs * task for all objects of the class. * */ public static int add(int first, int second) { return first + second; } } |
Nice Example…thank you very much
thanks for keeping the site
thanx e lot
This is really good site with nice examples.Thanks.
examples r superb….
easy to understand………..
thank u……..
really its a good plateform for studying
because u can learn only with the help of examples and u provide examples
best yaar!!!!!!
BOL
EXAMPLES ARE VERY EASY, IT SHOULD BE LITTLE HARD WITH ANSWERS SO THAT WE CAN IMPROVE OUR PROGRAMMING KNOWLEDGE.
You have provided very understandable examples. It is a good site to learn and refresh the java basics. Thanks a lot.
It’s very good example. I understood really that concept.
its very useful for examinations
its very useful for my career thanks lot…