java overriding not working
<p>I'm a beginner in Java, I used PHP, C++ and Lua and never had this problem, I made two classes just for exercising's sake <code>Facto</code> and <code>MyFacto</code>, first one does find a factorial and the second one should find factorial not by adding, but by multiplying. Don't blame me for the stupid and pointless code, I am just testing and trying to get the hang of Java. </p>

<p>Main:</p>

<pre><code>public class HelloWorld {
public static void main(String[] args) {

    Facto fc = new Facto(5);
    fc.calc();
    System.out.println(fc.get());   

    MyFacto mfc = new MyFacto(5);
    mfc.calc();
    System.out.println(mfc.get());

}
}
</code></pre>

<p>Facto.java:</p>

<pre><code>public class Facto {
private int i;
private int res;

public Facto(int i) {
    this.i = i;
}

public void set(int i) {
    this.i = i;
}

public int get() {
    return this.res;
}

public void calc() {
    this.res = this.run(this.i);
}

private int run(int x) {
    int temp = 0;
    if(x&gt;0) {
        temp = x + this.run(x-1);
    }
    return temp;
}
}
</code></pre>

<p>MyFacto.java:</p>

<pre><code>public class MyFacto extends Facto {
public MyFacto(int i) {
    super(i);
}

private int run(int x) {
    int temp = 0;
    if(x&gt;0) {
        temp = x * this.run(x-1);
    }
    return temp;
}
}
</code></pre>

<p>I thought the result should be 15 and 120, but I get 15 and 15. Why is that happening? Does it have something to do with <code>calc()</code> method not being overriden and it uses the <code>run()</code> method from the <code>Facto</code> class? How can I fix this or what is the right way to override something like this?</p>
