i am new to java is there is any possible way of calling a function within same class without creating a object for the class my program is
public class Puppy{
public Pup(String name){
System.out.println("Passed Name is :" + name );
}
public static void main(String []args){
public Pup( "tommy" );
}
}
i want to call function pup without creating object for it ,is it possible?
I'm not sure but maybe.... Inside your main method, you can simply use this statement,
Your Pup method should have a valid return statement and use these modifiers,
if it's a returning method
if it's a void method