royalcyber
asked on
static method
Hi ,
if i have a method static:
public static String authenticate ( String var1, String var2)
1)do i need to instantiate it with "new" command
2) whats the benefit of making the method static
30 what are the disadvantages of making the method static
thanks
RC
if i have a method static:
public static String authenticate ( String var1, String var2)
1)do i need to instantiate it with "new" command
2) whats the benefit of making the method static
30 what are the disadvantages of making the method static
thanks
RC
royalcyber,
For example if you have a class Base with a static method Index, then you don't have to create an object of the class Base for calling the function Index
For ex: if not static, Base b = new Base(); b.Index();
If static, Base::Index();
For example if you have a class Base with a static method Index, then you don't have to create an object of the class Base for calling the function Index
For ex: if not static, Base b = new Base(); b.Index();
If static, Base::Index();
Good place to read up on the differences;
http://www.leepoint.net/notes-java/flow/methods/50static-methods.html
http://www.leepoint.net/notes-java/flow/methods/50static-methods.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks :)
1) If you want.
2) You can call the method without creating the object of the class.
3) If you don't want, skip it, there is no disadvantage.
Bye
---
Harish