Create a class Author whose attributes are: name, email, gender and books. Author constructor initializes the values
of name, email, gender and books. Define a static variable, method and block, and use this keyword in your code.
import java.util.ArrayList;
public class Author {
private String name;
private String email;
private String gender;
private ArrayList<String> books;
private static int authors;
static {
authors = 0;
}
public Author(String name, String email, String gender, ArrayList<String> books) {
this.name = name;
this.email = email;
this.gender = gender;
this.books = books;
}
public static int getAuthors() {
return authors;
}
}
Comments
Leave a comment