im new to java so I imagine this is a very simple question but I cannot find my answer
Im creating a very simple game but when i come to compile my main I get
BattleShipGame.java:19: error: cannot find symbol
BattleShip ship = new BattleShip();
^
symbol: class BattleShip
location: class BattleShipGame
BattleShipGame.java:19: error: cannot find symbol
BattleShip ship = new BattleShip();
^
symbol: class BattleShip
location: class BattleShipGame
2 errors
So when i go to create my object in the main it cannot find the symbol and create the object
My battle ship class :
public class BattleShip {
//delcare an int arry to hold the location of the cells
private int[] location;
//setter for location
public void setLocation(int[] shipLocation){
location = shipLocation;
}
public String checkGuess(String[] g){
//return the message
return message;
}
}
Main method :
public class BattleShipGame {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//create a battle ship object
BattleShip ship = new BattleShip();
//hard code location of ship
int[] ShipLocation = {4,5,6};
//set the location of the object
ship.setLocation(ShipLocation);
//take the users guess from command line
String[] guess = {args[0], args[1], args[2]};
//take message returned from method
String message = ship.checkGuess(guess);
// print out the message
System.out.println(message);
}
}
If anyone could let me know why i cant create an object?
I compiled the battleship class before the main These are both in the same package do I still have to import?