Here's the code where I'm receiving the error (at the second "Killer" after "new").
String[] classes = new String[5];
kills[0] = "Brian Moser";
kills[1] = "James Doakes";
kills[2] = "Lila Tourney";
kills[3] = "Miguel Prado";
Killer morgan = new Killer("Dexter",
"Morgan",
kills,
4.0,
"Arthur Mitchell",
3,
false);
This has been giving me quite a bit of trouble, as I see no reason why this declaration should work based on my constructor for Killer.
And here's the Killer class:
import java.util.*;
public abstract class Killer{
public String firstName;
public String lastName;
private String[] killList;
private double score;
private String nemesis;
private int accidents;
public boolean caught;
public Killer(String firstName,
String lastName,
String[] killList,
double score,
String nemesis,
int accidents,
boolean caught)
{
this.firstName = firstName;
this.lastName = lastName;
for(int i = 0; i < 5; i++)
this.killList[i] = killList[i];
this.score = score;
this.nemesis = nemesis;
this.accidents = accidents;
this.caught = caught;
} //end constructor
I know this probably has a simple solution, but as of now, I'm not seeing it.
following are few main points about abstract classes
in your case there is a abstract class declared as public abstract class Killer so as its declaration defines that it is public, abstract class with named as Killer so as it is stated earlier that an Abstract classes cannot be instantiated so you need to subclass it or remove abstract keyword in order to get its instance for further read oracle docs abstract classes
We can't instantiate abstract class. It's characteristics of abstract class. Here it's abstract so.