不正な URL を取得した場合に例外をスローするオブジェクト "LinkFinder" がありますが、System.out を使用してエラーを出力するという考えは好きではありません。コンストラクターが初期化されたオブジェクトを返す代わりに、null または何かを返すように強制できますか?
private URL url;
//constructor in question
public LinkFinder(String sourcePage)
{
try
{
this.url = new URL(sourcePage);
}
catch (MalformedURLException e)
{
System.out.print("Malformed URL Exception: Setting URL to NULL");
this.url = null;
}
}