// 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
Shipclass.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
mainmethod is defined. You can rename the classShipMain1toShipor set a argo as an instance ofShipMain1.