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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:40:12+00:00 2026-05-26T21:40:12+00:00

Im trying to use an integer, that Im using in one class and also

  • 0

Im trying to use an integer, that Im using in one class and also use the SAME int in a different class.
I forgot, what do I have to do for that?

static? implements? extends? what?

Best regards,

For simplicity:

      public class ETBetaActivity extends Activity implements View.OnClickListener {
      public static int anInt = 50;

Another class

            public class GUI extends Activity implements View.OnClickListener {
             public static int anInt_2 = 5+anInt;
  • 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-26T21:40:12+00:00Added an answer on May 26, 2026 at 9:40 pm

    static is used to set that value to class, so all objects of the class will have that.

    example:

      public class FirstClass
      {
          public static int yourInt;
      }
    

    and you can access it like this: FirstClass.yourInt

    You should consider the following example, if you want to avoid static:

    public class FirstClass  
    {
       private int yourInt;
    
       public getInt(){return this.yourInt;}
       public setInt(int _int){ this.yourInt = _int}
    }
    

    and from all the classes you can use this using getters and setters. Note that if you use 2nd method (with getter and setters ) you will have different values for yourInt, for each object you create, and that value should be set on constructor .

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

Sidebar

Related Questions

I have several different tables in my database and I'm trying to use Sphinx
I'm trying to use a hardcoded 64bit integer in a string variable. Simplfied I
I'm trying to use Boost regex to see if something has an integer in
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Trying to use an excpetion class which could provide location reference for XML parsing,
I am trying to learn Free Pascal using Lazarus and one of my pet
I have been trying to develop some user controls, one being a text edit
When I use a rewrite rule that splits an insert into one table into
I’m trying to determine the relationship of a given compiler’s integer types’ sizes using
I have a class that looks like this: class SearchService include Mongoid::Document key :name,

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.