title: Having trouble with this java code - supposed to print and count number of heads and tails in a random coin toss
body: <p>So as the title says, I have to use a class file and also a main method java file that calls the class file and prints out the starting coin face, as well as 40 more coin face flips. I also need to have 2 counters that count the number of heads and number of tails. Here is my code for my class file and main method file. The problem I'm having is that whenever I run it, it always prints out that heads has 0 count and tails as 40 counts.</p>
  
  <p><strong>Class File:</strong></p>
  
  <pre><code>import java.util.Random;
  
      public class CoinToss 
      {
      private String sideUp;
  
      public CoinToss()
      {
          Random randomNum = new Random();
          int number = randomNum.nextInt();
  
          if(number%2 == 0)
              sideUp = "heads";
          else
              sideUp = "tails";
  
          System.out.println(sideUp);
      }
  
      public void toss()
      {
          Random randomNum = new Random();
          int number = randomNum.nextInt();
  
          if(number%2 != 0)
          {
              sideUp = "heads";
          }
          else
          {
              sideUp = "tails";
          }
  
          System.out.println(sideUp);
      }
  
      public String getSideUp()
      {
          return sideUp;
      }
  
      }
  </code></pre>
  
  <p><strong>Main Method File</strong></p>
  
  <pre><code>public class CoinTossDemo 
  {
  public static void main(String[] args)
  {
      int headsCount = 0;
      int tailsCount = 0;
  
      System.out.print("The Starting side of the coin is: ");
      CoinToss coin = new CoinToss();
      System.out.println();
  
      for(int x = 0; x &lt; 40; x++)
      {
          System.out.print("The next side of the coin is: ");
          coin.toss();
          System.out.println();
  
          if(coin.equals("heads"))
          {
              headsCount++;
          }
          else
          {
              tailsCount++;
          }
      }
  
      System.out.println("The amount of heads that showed up is: " + headsCount);
  
      System.out.println();
  
      System.out.println("The amount of tails that showed up is: " + tailsCount);
  }
  }
  </code></pre>
  
  <p>Please help, thanks in advance.</p>