What is the gain from declaring a method as static

后端 未结 9 551
别跟我提以往
别跟我提以往 2020-12-07 10:35

I\'ve recently been looking through my warnings in Eclipse and come across this one:

\"static

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-07 11:27

    From the Android Performance guidelines:

    Prefer Static Over Virtual If you don't need to access an object's fields, make your method static. Invocations will be about 15%-20% faster. It's also good practice, because you can tell from the method signature that calling the method can't alter the object's state.

    http://developer.android.com/training/articles/perf-tips.html#PreferStatic

提交回复
热议问题