I'm a beginner in java using VS Code and I'm creating a simple program that just makes a board. For some reason when I go into my terminal to compile the Main class it gives me these errors. But in debug mode it works just fine, why is this?
PS C:\Users\blake\Desktop\javavscode\BattleShip> javac Main.java
Main.java:10: error: cannot find symbol
Board board = new Board(input);
^
symbol: class Board
location: class Main
Main.java:10: error: cannot find symbol
Board board = new Board(input);
^
symbol: class Board
location: class Main
Here are is my code:
package BattleShip;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("What size do you want the board to be?: ");
int input = Integer.valueOf(scanner.nextLine());
Board board = new Board(input);
board.print();
}
}
package BattleShip;
public class Board {
private char[][] board;
private char water = '~';
private int size;
public Board(int size){
this.size = size;
this.board = new char[size][size];
for (int i = 0; i < board.length; i++){
for (int j = 0; j < board.length; j++){
board[i][j] = water;
}
}
}
public void print(){
for (int i = 0; i < board.length; i++){
for (int j = 0; j < board.length; j++){
System.out.print(board[i][j] + " ");
}
System.out.println("");
}
}
}
In vscode when i used debug and then run it works for some reason but I don't understand what this really means
PS C:\Users\blake\Desktop\javavscode\BattleShip> c:; cd 'c:\Users\blake\Desktop\javavscode'; & 'C:\Users\blake\AppData\Local\Programs\Eclipse Adoptium\jdk-17.0.7.7-hotspot\bin\java.exe' '-XX:+ShowCodeDetailsInExceptionMessages' '-cp' 'C:\Users\blake\AppData\Roaming\Code\User\workspaceStorage\b656ed2f78ffde906270d9c291aeeeb0\redhat.java\jdt_ws\javavscode_a7ed4f9c\bin' 'BattleShip.Main' What size do you want the board to be?:
Also in my directory for the Board and Main class, there are now Board.class and Main.class, do i need to use these instead?