How to make the value of a variable inside a Java Private method available/visible to another java file?
<p>I have a Private method in a java file within which I have a variable called maxRate. I need the value of maxRate in another java file to compare it with another variable minRate.</p>

<p>How do I make the maxRate variable visible to another java file?</p>

<p>My code is as follows
    A.java (in a diff package)</p>

<pre><code>public class A{

  private Integer maxRate = null;

  private modelAndView dConfig(int a,string b,string c, string d, string e){
    Map&lt;String, PropConf&gt; map = getConf(b,c,d,e);
    PropConf propConf = map.get(getKey(a));
    Integer maxRate = propConf.getMaxRate();
  }
}
</code></pre>

<p>Problem:
I need the value of maxRate in B.java which resides in a different package.</p>

<p>Progress:</p>

<p>As of now as per suggestions, I declared maxRate as private Integer maxRate on the top within the public class A{ and have also declared a getter method in A.java as follows,</p>

<pre><code>public Integer getMaxRate(){
return this.maxRate
}
</code></pre>

<p>then I tried calling getMaxRate from within B.java as follows,
    B.java</p>

<pre><code>public ModelAndView save() {

A a = new A();
Integer f = a.getMaxRate();
logger.debug("F is" +f); }
</code></pre>

<p>The f value was printed as null.</p>
