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

  • SEARCH
  • Home
  • 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 1064151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:53:17+00:00 2026-05-16T18:53:17+00:00

Apologies if this ends up being a stupid question, but I was just wondering

  • 0

Apologies if this ends up being a stupid question, but I was just wondering why this is done on step 9 of the Notepad Exercise 1 tutorial (http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html) …

public static final int INSERT_ID = Menu.FIRST;

… and then INSERT_ID is used everywhere, instead of just using Menu.FIRST directly instead everywhere?

I was thinking that I don’t want to create any new variables if I don’t have to, especially when they are static final already.

Is it expensive to create INSERT_ID?

  • 1 1 Answer
  • 1 View
  • 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-16T18:53:18+00:00Added an answer on May 16, 2026 at 6:53 pm

    Because if you used Menu.First everywhere then decided to move that option in the menu so that it was no longer the first item you would need to update all the references. This way you only need to update it in one place and the more sensibly named INSERT_ID will reflect the changes that you have made everywhere else.

    As for the performance hit of creating new variables: Yes, creating the variable will use up a (insignificant) amount of CPU time, and yes storing the variable will use up an (insignificant) amount of memory, but you should never put performance before code readablity until you have determined that you have hit a bottleneck – you’d be in a very restricted environment for this to be anything near a problem.

    Finally, a lot of compilers will inline the references to INSERT_ID anyway. This means that all references to INSERT_ID will be replaced at compile time with the value in Menu.First and the variable will never actually be created. I don’t know enough about the Android compiler to say for sure one way or the other, but I would be surprised if it didn’t do this.

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

Sidebar

Related Questions

Apologies if this is a silly question, but I'm just wondering the best way
Apologies if this is a stupid question but it is quite hard to find
Apologies if this is a slightly noob question, but looking to clarify my thoughts
Apologies if this question is a duplicate, or if I've missed something, but in
Apologies if this is a duplicate, but I've not managed to find this question
Apologies if this is a stupid question - I'm an Android and Ant newbie.
Apologies for this seemingly redundant question, but the others all seem to be asking
Apologies if this is a newbie question, but I have been unable to resolve
My apologies if this is a dumb question, but I can't seem to find
Apologies if this is an overly simple question, but my searches are getting me

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.