• Constructor or builder?


    In the process of instantiating a class, constructors with multiple parameters are usually encountered, but what if some parameters are not required? Do you want to initialize so many parameters every time? public class Person { Private int ID; // ID card No Private string name; // name Private int age; // age Private Boolean […]

  • Database exercise (student table)


    Create table 1. Create student table, score table and course table create  table student(  sid     int(11) primary key not null,  sname   char(25) not null,  age     int(11) not null,  sex     char(2) not null,  department char(40) ,  address  char(200) ,  birthplace  varchar(256) ); create  table sc(   sid   int(11) not null,   cid   int(11) not null,   […]

  • Java custom exception


    Custom exception   1、Inheritance class       Generally, you choose to inherit Exception.andRuntimeExceptionIf the caller is not required to handle the thrown exception, inheritRuntimeException。   2、Custom Exception Class Construction Method     Code examples: People entity class public class People { String name=””; int age=0; String sex; public String getSex() { return sex; } public […]