title: How to modify a method from another class
body: <p>I have the following class called <code>A</code>, with the method <code>getValue()</code>:</p>
  
  <pre><code>public class A {
      public final int getValue() {
          return 3;
      }
  }
  </code></pre>
  
  <p>The method <code>getValue()</code> always returns <strong><em>3</em></strong>, then i have another class called <code>B</code>, i need to implement something to access to the method <code>getValue()</code> in the class <code>A</code>, but i need to return <strong><em>4</em></strong> instead <strong><em>3</em></strong>.</p>
  
  <p>Class <code>B</code>:</p>
  
  <pre><code>public class B {
    public static A getValueA() {
      return new A();
    }
  }
  </code></pre>
  
  <p>The main class <code>ATest</code>:</p>
  
  <pre><code>import org.junit.Test;
  import static org.junit.Assert.assertEquals;
  import org.junit.runners.JUnit4;
  
  public class ATest {
  
      @Test
      public void testA() {
          A a = B.getValueA();
          assertEquals(
              a.getValue() == 4,
              Boolean.TRUE
          );
      }
  }
  </code></pre>
  
  <p>I tried to override the method, but really i dont know how to get what i want. Any question post in comments.</p>