Java new object instance changing the old instances
<p>So I'm currently trying to construct Sentences in Propositional Logic in java but I ran into a problem with what is probably basic Java but I've tried researching it and I don't know what's actually wrong. </p>

<p>The problem I'm running into is that when I construct a new Complex Sentence (which has a binary connective, a left side, and a right side) it changes my old sentences. How can it change previous instances if I'm initiating a brand new one and not even adding it to the KB(Knowledge Base)? When I ran the debugger it looks like when the new 2nd sentence is being constructed, it still uses the old instance, as the old instance was the "this" in the debugger variables.  </p>

<p>Here is my main method:</p>

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

    runModusPonens();
}


public static void runModusPonens(){
    KB modusKB=new KB();
    Symbol p=modusKB.intern("P");
    Symbol q=modusKB.intern("Q");
    modusKB.add(p);
    Sentence im=new ComplexSentence(LogicalConnective.IMPLIES,p,q);

    modusKB.add(im);

    modusKB.printWorld();

    Sentence i=new ComplexSentence(LogicalConnective.AND,q,p);

    modusKB.printWorld();
}
</code></pre>

<p>**The output is:</p>

<p>First modusKB print out:</p>

<pre><code>P

(P IMPLIES Q)
</code></pre>

<p>Second modusKB print out (after the 2nd sentence was created)</p>

<pre><code>P

(Q AND P)   //--&gt;Should still be (P IMPLIES Q)**
</code></pre>

<p>And my ComplexSentence class</p>

<pre><code>public class ComplexSentence implements Sentence{
//Sentence structure: leftSide(left hand side sentence) binarycon(connective) rightSide(right hand side sentence)
public static LogicalConnective binarycon;
public static Sentence leftSide;
public static Sentence rightSide;

public ComplexSentence(LogicalConnective connective,Sentence left, Sentence right){
    binarycon=connective;
    leftSide=left;
    rightSide=right;
}



public String toString() {
    return "("+this.leftSide+" "+this.binarycon+" "+this.rightSide+")";
}

}
</code></pre>

<p>Note: Sentence interface doesn't have anything in it yet so can't be it. </p>