Skip to content
Quiz · Final project · lesson 2 of 4

Quiz — what the project prints

What does the program print?

JAVA
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"); } }