I have an example class below and I want to return all class fields of certain type, in this example of type Image.
public class Contact {
private String surname, lastname, address;
private int age, floor;
private Image contactPhoto, companyPhoto;
private boolean isEmployed;
public String[] getAllImages() {
String images[] = // missing code
return images;
// in this case, I want to return {"contactPhoto","companyPhoto"}
}
}
I need a help here. How can I find all class fields of certain type. I will be calling this method in another class ofc.