calling a function in java without declaring a object -
i new java there possible way of calling function within same class without creating object class program
public class puppy{ public pup(string name){ system.out.println("passed name :" + name ); } public static void main(string []args){ public pup( "tommy" ); } }
i want call function pup without creating object ,is possible?
you can declare method static:
public static void pup(string name){ ... }
as aside: should use standard java naming conventions , start method name lower-case letter:
public static void pup(string name){ ...
Comments
Post a Comment