Тест · Итоговый проект · урок 2 из 4
Тест — что выведет проект
Что выведет программа?
import java.util.HashSet;
public class Main {
static HashSet<String> out = new HashSet<>();
static void borrow(String t) throws LoanException { if (!out.add(t)) throw new LoanException(t); }
public static void main(String[] args) {
try {
borrow("Dune");
borrow("Dune");
} catch (LoanException e) { System.out.println(e.getMessage()); }
}
}
class LoanException extends Exception { LoanException(String t) { super(t + " is out"); } }