I am having some issues understand something about abstract classes. I have an abstract class created with a method for setting/getting a name:
public abstract class Person {
private String firstName;
public void setFirstname(String name)
{
this.firstName = name;
}
public String getFirstName()
{
return firstname;
}
I have 2 other classes that extend this class and they are Worker and Employer. I have the different workers and employers being created and stored into arraylists in a forth class called WorkPlace. My question is if I wanted to get every first name of every Person is there a way to do it without going through each arraylist and doing something like workerList.get.getFirstName?
Personinstances inArrayList, no.abstractin the class signature on the first line. An abstract class may work without additional functionality, but can be declared abstract to intend that it requires some extras making it meaningful. It doesn't need to have any extra methods declaredabstract.