0

What is static methods ? How to call them

5th Feb 2022, 6:28 AM
Kaustubh Dabhade
Kaustubh Dabhade - avatar
3 ответов
+ 2
In contrast to non-static methods (which involves initializing and using an object), static methods are invoked through the class name. Most of the methods in the Math class, for example, are static methods. You would call the abs(int a) function like this: int num = -100; System.out.println(Math.abs(num)); =================== What you would NOT do: int num = -100; Math obj = new Math(); System.out.println(obj.abs(num));
5th Feb 2022, 8:21 AM
Solus
Solus - avatar
0
I need more simple definition and clear example
5th Feb 2022, 8:34 AM
Kaustubh Dabhade
Kaustubh Dabhade - avatar
0
Java Software Solutions 9th Edition PDF --> chapter 7.3. Read this and do the self-review questions at the end of the chapter. Answers are in Appendix L.
5th Feb 2022, 9:02 AM
Solus
Solus - avatar