デフォルトのコンストラクターが Java で使用されないようにするにはどうすればよいですか?
私の評価では、次のように述べています。
"We don't want the user to use the default constructor since the user has to specify the HashCode, and maximum load factor"
これでうまくいくと思いましたが、どうやらそうではありません(辞書は例外をスローするために使用されるクラスです):
public boolean HashDictionary() throws DictionaryException {}
DictionaryException クラス:
public class DictionaryException extends Throwable {
}
デフォルトのコンストラクター (講師提供) を使用したときに例外がスローされることを確認するためにテストします。
try
{
HashDictionary h = new HashDictionary();
System.out.println("***Test 1 failed");
}
catch (DictionaryException e) {
System.out.println(" Test 1 succeeded");
}
私はそれを行う方法に慣れていないので、これを行う方法を知りたいだけです。ありがとう。