0
public class VerifyFactory {

    private static final VerifyFactory INSTANCE = new VerifyFactory();

    private VerifyFactory() {
    }

    public static VerifyFactory getInstance() {
        return INSTANCE;
    }

    public Verifiable getVerifyForEntryConference(ServerOperations serverOperations, String logPath,
         language);
    }

    public Verifiable getVerifyForEntryTone(ServerOperations serverOperations, String logPath,


    }


    }


public class VerifyFactory {


    public static Verifiable getVerifyForEntryConference(ServerOperations serverOperations, String logPath,
         language);
    }

    public static Verifiable getVerifyForEntryTone(ServerOperations serverOperations, String logPath,


    }


    }

static method vs object method which is better in such code sample.

CloudyMarble
  • 36,908
  • 70
  • 97
  • 130
jiafu
  • 6,338
  • 12
  • 49
  • 73

2 Answers2

0

"static method vs object method which is better" well it depends on the purpose of your usage.

If you want your method to be called up only after an instance of the class (containing that method) has been created, then you should define that method as non-static

And if you want to call your method without creating an instance of the class, then you should define your method as static

Abubakkar
  • 15,488
  • 8
  • 55
  • 83
0

Object method is much better than static but it depend on method and requirements. i generally used static when it is not possible to create object before method call. and if your class has some instance variable then use object methods. you can't use class instance variables in static method.

object methods are specific to objects but static methods are not.

So if your method is not interfering with instance variables then you can make them static.

you can check this Ques. also : Difference between Static methods and Instance methods

Community
  • 1
  • 1
Arpit
  • 12,767
  • 3
  • 27
  • 40
  • but in this place, it both can create instance or not to call . So I can't make a choice for which one. – jiafu Feb 05 '13 at 06:20
  • @jiafu this is what i said in first line."it depend on method and requirements" – Arpit Feb 05 '13 at 06:21