Why comparing strings inside a method doesn't work? : <p>I've got 2 classes, object of the second class is created inside the first class. I'm using next() method to increase the value of seconds, then I want to check if its value is 0 and cannot get through by using .equals("0") method. </p>

<p>I'm writing in Eclipse, java 11</p>

<pre><code>public void tick(){
      seconds.next(); //var "seconds" is of type second class(calling 
                       //      seconds means toString() from 2nd class)
      if(seconds.equals("0")) { 
          System.out.println("CANNOT ACCESS THIS ????");
      }
</code></pre>

<p>Method next() from second class: </p>

<pre><code>public void next() {
        if(value==upperLimit)   value=0;
        else ++value;
    }

    public String toString() {
        return value+"";
    }
</code></pre>

<p>I expect to run first if statement inside tick() method, but it doesn't.</p>
