Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3402324
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:07:26+00:00 2026-05-18T05:07:26+00:00

I just read an article in the BlackBerry docs about writing efficient code in

  • 0

I just read an article in the BlackBerry docs about writing efficient code in J2ME.

In that article there is a section that advises you to “use static variables for Strings.” The reasoning is that, since the compiler inlines static final references as string literals, it’s better to leave it non-final (I guess the assumption is that retrieving a static reference is cheaper than retrieving from the string pool?).

Is this true for all JVMs?? My boss at my last job pounded it into our heads that we should always, always use static final for our constants. We were doing embedded programming in Java, so he was a real stickler for performance (although I’m not sure in this case whether he was more concerned with memory or speed). My boss has been doing Java for years and really knows his stuff, so I took his advice; now I’m getting contradictory advice!

So which one is really better? You can answer from either a memory conservation perspective or a speed perspective, and for either J2ME or J2SE.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:07:27+00:00Added an answer on May 18, 2026 at 5:07 am

    In general, they should be the same. (With the same defined as close enough that it will never ever matter)

    I would very strongly argue that you should encode your intent (i.e. having the static vs non-static-ness defined by whether this is a class constant versus an instance constant) rather than some arbitrary “performance enhancement”

    If you find that this is a significant performance problem (and only AFTER you measure it!), I would classify it as a compiler / JVM defect and put the workaround (Swapping its static-ness) in place, with a comment indicating why.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just got Delphi 2009 and have previously read some articles about modifications that
I just read an article that describes how HttpApplicationState has AcquireRead() / AcquireWrite() functions
I just read this article from Google. I always thought that closing tags is
i just read this article : https://developer.mozilla.org/en/HTTP_Caching_FAQ There's a firefox behavior (and some other
I just read this article about the Entity Framework 4 (actually version 2). Entity
So I just read this article . What I'm wondering is, is there any
I just read the Wikipedia article on mock objects , but I'm still not
I just read Joel Spolsky's article, Up the tata without a tutu , where
I just read up on a performance of LINQ, and there is a HUGE
I just read this post about why new-line warnings exist, but to be honest

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.