Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Static variables and performance....

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are some performance problem if I use static final variables and static methods into other class file and call this from a servlet ?
 
Sheriff
Posts: 6959
2
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not especially.
Sure, there might be a (very slight) performance issue when the other class is first loaded, but only if is loaded from a remote location over a network, but that is really rare.
Much more likely is that the other class you are using may have lots of dependencies on yet other classes, even though the static method you are calling does not make use of them. This can lead to "code bloat", where a lot of unused classes need to be deployed with your application just to satisfy the compiler. I know of several "utilitiy" jars that have this problem.
Calling methods from other classes is generally a good thing, unless the other classes have taken on too many responsibilitie sand become bloated.
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both static and non-static method calls are VERY VERY VERY fast, and will make no practical difference.
 
reply
    Bookmark Topic Watch Topic
  • New Topic