OO Programming with Java


Being in the Java world, all the API is available with collections' types, databases connectors, etc.

  1. Adding data

As an illustration, the users from the application can be stored as follow:

public class Users extends HttpServlet {
  record User(String name, String mark) {}
  public static ArrayList<User> users = new ArrayList<User>();
  static {
    users.add(new User("bill","13"));
    users.add(new User("kate","18"));
  }
... // add to doGET():
  for (User u : users)
    out.println("<li>"+u.name+" - "+u.mark+"</li>");

Then, the recompilation will leads to an application with data:

Nb. In the example, a stylesheet (.css) has been added and saved in static directory.


7 - 16