I have a subclass that needs to inherit a method and a variable, and I want to be able to make several instances of the subclass. However, I can't change health
's value from the class Glob.
Here is my code:
public class Monster
{
int health;
public int getHealth()
{
return health;
}
}
class Glob extends Monster
{
health = 6; // <- Error
}