最近、私は XML パーサーを扱っています。これは私にとってはまだ始まったばかりで、Java ie で DOM パーサー クラスを使用する方法と、XML ドキュメントを解析する方法を理解することができましDocumentBuilderFactory
たDocumentBuilder
。
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
私が自問しているのは、 や などの抽象クラスDocumentBuilderFactory
がDocumentBuilder
新しいインスタンスをインスタンス化できるのはなぜですか? そして、別の例では次のように表示されます。
Calendar calendar = Calendar.getInstance();
System.out.println(calendar.get(Calendar.DATE));
- 私の知る限り、抽象クラスとインターフェイス クラスのインスタンス化 (つまり、オブジェクトの作成) はできません。私は正しいですか?
getInstance()
メソッドとnewInstancce()
メソッドは、上記の抽象クラスのインスタンスを作成しますか?
抽象クラスとその新しいオブジェクトの使用について何か不足していますか?