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 8989641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:18:39+00:00 2026-06-15T22:18:39+00:00

Sometimes I see something like : public class MainActivity extends Activity { public static

  • 0

Sometimes I see something like :

public class MainActivity extends Activity
{
    public static final String url_google = "http://www.google.com";

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }    
}

What I actually don’t get, is why using public static final , and not public final or final

  • 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-06-15T22:18:41+00:00Added an answer on June 15, 2026 at 10:18 pm

    I’m speaking very broadly, but if it’s final, you only need one instance of it anyways, so it saves memory by making it static.

    To be more specific, the final keyword means that whatever the variable stores cannot be changed. This means that once the variable has a value, you may use the variable, but you cannot modify it in any way. Commonly, to give a value to a final variable, you do so right from the declaration eg final int variable = 12. As you can see I used an int for my example, however you can use anything, including reference variables. Reference variables, are special though, because you cannot change what the variable points to, but you can change the Object itself (such as using get/set methods).

    What this boils down to though, is that once you have made a final variable it occupies space in memory. Since we can’t modify this variable further, why should we recreate it every time our Class is instantiated? So we use the static keyword. This allows the variable to be created once, and only once in memory.

    There are though, some specific cases in which you would want to not use static and use just final. One example may be time sensitive variables, such as storing the time of Object instantiation.

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

Sidebar

Related Questions

When I compile something like this: public class MyClass { void myMethod(String name, String
Sometimes I see something like this which I quite don't understand: // ... that.constructor
Sometimes in Strings I see something like this %1$s or this %2$d . Can
I have a strange problem. When I enter my site http://www.dinomuhic.com I sometimes see
I sometimes see messages like Process 12990 waits for ExclusiveLock on tuple (889,66) of
When creating iPhone apps in simulator, I sometimes see messages like Springboard failed to
sometimes i see an image not being served when the browser look at www.somesite.com/some_image.jpg
Sometimes I see code like let (alt : recognizer -> recognizer -> recognizer) =
Sometimes I see people use http://codepad.org as a way to quickly run/test their Perl
In code, I sometimes see people specify constants in hex format like this: const

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.