title: Why is my second object created from my Board class not printing out the same game board filled with battleships like my first object?
body: <p>I'm creating a Battleship game for my Java course (might not be the best code structure or the neatest but I'm trying). I'm running across a problem where I create two objects from my Board class and only one of the objects prints out a board game filled with water and battle ships while the second one if not filled with battleships. I'm confused to why the second object won't print out the same results as the first objects if they're completely different objects themselves I thought that's how object oriented programming worked? I've tried even creating a second createBoardGame2() method to see if that would help it create a different result if the original method stopped working after using it for the first object for some reason.</p>
  <pre><code>public class Main {
      public static char hit = 'X';
      char miss = 'O';
      public static char water = '-';
      public static char ship = 'S';
      int i = 0;
      public static Board board = new Board(10, 10, water, ship);
      public static Board playerOwnBoard = new Board(10, 10, water, ship); // Creates opponent board game which we will do guesses on
      public static int shipsNum = 5;
  
      public static void main(String[] args) {
  
          playGame();
  
      }
  
      static void playGame() {
          playerOwnBoard.printBoardGameOwn(playerOwnBoard.createBoardGame());
          board.printBoardGameOwn(board.createBoardGame());
  
          int undetectedShipNumber = shipsNum;
          
      }
  
  }
  
  import java.util.Arrays;
  import java.util.Random;
  import java.util.Scanner;
  
  public class Board {
      private static final int xAxis = 10;
      private static final int yAxis = 10;
      // Symo
      public static char water = '-';
      public static char ship = 'S';
      public static char hit = 'X';
      public static char miss = 'O';
      // Number of ships allowed are no more than 1
      private static int placedShips = 0;
      private static int battleship = 0;
      private static int carrier = 0;
      private static int destroyer = 0;
      private static int submarine = 0;
      private static int patrolBoat = 0;
      private static int shipsNum = 5;
      private static final char[] BOARD_LETTERS = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'}; // Row input on grid
      //public static char[][] boardGame;
  
      public static int[][] carrierShip = new int[5][2];
      public static int[] guessCoordinates;
      public static char locationViewUpdates;
  
      static Scanner sc = new Scanner(System.in);
  
    
      public char[][] createBoardGame() {
          char[][] boardGame = new char[xAxis][yAxis];
          for (char[] row : boardGame) {
              Arrays.fill(row, water);
  
          }
          return placeShips(boardGame);
      }
  
      public static void printBoardGameOwn(char[][] boardGame) {
          int j = 0;
          for (int i = 1; i &lt;= yAxis; i++) {
              System.out.print(&quot;\t&quot; + i);
          }
          System.out.println();
  
          for (int row = 0; row &lt; boardGame.length; row++) {
              System.out.print(BOARD_LETTERS[j] + &quot; | &quot;);
  
              for (int col = 0; col &lt; boardGame.length; col++) {
                  char position = boardGame[row][col];
                  if (position == ship) {
                      System.out.print(ship + &quot; | &quot;);
                  }
                  else {
                      System.out.print(position + &quot; | &quot;);
                  }
              }
              j++;
              System.out.println();
          }
      }
  
      public static char[][] placeShips(char[][] boardGame) {
          int gameBoardLength = boardGame.length;
          while (placedShips &lt; shipsNum) {
              int location = generateShipCoordinates(gameBoardLength);
              int location2 = generateShipCoordinates(gameBoardLength);
  
              char possiblePlacement = boardGame[location][location2];
              if (possiblePlacement == water &amp;&amp; carrier == 0 &amp;&amp; location2 &lt; 6) {
                  for (int q = 0; q &lt; 5; q++) {
                      if (possiblePlacement == water) {
                          boardGame[location][location2] = ship;
                          carrierShip[q][0] = location;
                          carrierShip[q][1] = location2;
  
                          location2++;
                      }
                  }
                  carrier++;
                  placedShips++;
              }
              else if (possiblePlacement == water &amp;&amp; battleship == 0 &amp;&amp; location2 &lt; 7) {
                  for (int q = 0; q &lt; 4; q++) {
                      if (possiblePlacement == water) {
                          boardGame[location][location2] = ship;
                          location2++;
                      }
                  }
                  battleship++;
                  placedShips++;
              }else if (possiblePlacement == water &amp;&amp; destroyer == 0 &amp;&amp; location2 &lt; 8) {
                  for (int q = 0; q &lt; 3; q++) {
                      if (possiblePlacement == water) {
                          boardGame[location][location2] = ship;
                          location2++;
                      }
                  }
                  destroyer++;
                  placedShips++;
              }else if (possiblePlacement == water &amp;&amp; submarine == 0 &amp;&amp; location2 &lt; 8) {
                  for (int q = 0; q &lt; 3; q++) {
                      if (possiblePlacement == water) {
                          boardGame[location][location2] = ship;
                          location2++;
                      }
                  }
                  submarine++;
                  placedShips++;
              }else if (possiblePlacement == water &amp;&amp; patrolBoat == 0 &amp;&amp; location2 &lt; 9) {
                  for (int q = 0; q &lt; 2; q++) {
                      if (possiblePlacement == water) {
                          boardGame[location][location2] = ship;
                          location2++;
                      }
                      else {
  
                      }
                  }
                  patrolBoat++;
                  placedShips++;
              }
          }
          return boardGame;
  
      }
  
      public static int generateShipCoordinates(int gameBoardLength) {
          int coordinates = 0;
          for (int i = 0; i &lt; gameBoardLength; i++) {
              coordinates = new Random().nextInt(gameBoardLength);
          }
          return coordinates;
      }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/fdqez.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fdqez.png" alt="sample output" /></a></p>
  <p>Second boardgames should be filled like the first with different locations for the S</p>