title: Pass integer between classes in Java
body: <p>So I have this class where I push a button, and at the and I get the int <code>maxpluseen</code> which I want to pass over to ClassB.</p>
  
  <pre><code>   private void populateBtn() {
          foto1 = (Button) this.findViewById(R.id.button2);
          foto1.setOnClickListener(new View.OnClickListener() {
              @SuppressLint("SimpleDateFormat")
              @Override
              public void onClick(View v) {
   int maxpluseen = maxIndex + 1;
                  Log.d("LOG!", "Uiteindelijk resultaat " + maxpluseen);
  
                  Intent myIntent = new Intent(classA.this, classB.class);
                  classA.this.startActivity(myIntent);     
  
              }
  
  
          });
      }
  </code></pre>
  
  <p>I tried doing the following:</p>
  
  <pre><code>public static int Access(int maxpluseen){
    return maxpluseen; 
  }
  </code></pre>
  
  <p>And In classB</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.info);
  
       int maxpluseen = 0;
      int test = classA.Access(maxpluseen);
      Log.d("LOG!", "Test int tussen klassen= " + test);
  
  }
  </code></pre>
  
  <p>But it gives back 0 (so my int isn't passed from <code>classA</code> to <code>classB</code>. What am I doing wrong here? </p>