// An illustration of object creation.
class ShipMain1 {
public static void main(String[] args){
// Define a method variable to refer to a Ship object.
Ship argo;
// Construct a new Ship object.
argo = new Ship();
}
}
When I go to compile it, it tells me symbol can not be found for the Ship in both Ship argo and argo = new Ship(); please help I'm an extremely new beginner. I'm also copying this out of a programming book so I don't know why it's not working.
An object is an instance of a class. You need thus to have a class defined somewhere. In your case, you certainly forgot to copy the
Ship
class.You can just create the missing class the same way you created
ShipMain1
. No need to create any method. The following should work.A faster solution is to use the class where the
main
method is defined. You can rename the classShipMain1
toShip
or set a argo as an instance ofShipMain1
.