2

I know that you should make a public method static if you need to access it without creating an Object of that class.

But what is the use of a priavte static method since you are not able to access it outside of the class?

Harout Tatarian
  • 431
  • 4
  • 14
  • 1
    Here is another variation of that question. http://stackoverflow.com/questions/538870/should-private-helper-methods-be-static-if-they-can-be-static – Sergii Khaperskov Jun 06 '15 at 00:54
  • Its just a matter of preference. It makes no noticeable difference to performance. It might give a hint to your fellow developers that the method doesn't interact with instance data. – bhspencer Jun 06 '15 at 01:01
  • @SergiiKhaperskov Yes, But not exactly. – Harout Tatarian Jun 06 '15 at 01:17
  • private static method makes sense when it is an implementation detail and it has a very localized use on the instance of a class or on another public static method – Michael Buen Jun 06 '15 at 01:32

0 Answers0