S
S
Someone Nektovich2018-09-26 16:39:59
Java
Someone Nektovich, 2018-09-26 16:39:59

Why doesn't the compiler see newInstance()?

Good afternoon!
I'm trying to get a new DocumentBuilderFactory instance,
all required packages are specified,
but the compiler refuses to see the newInstance() method;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
public class Main {
    public static void main() throws ParserConfigurationException {

        DocumentBuilderFactory factory = new DocumentBuilderFactory.newInstance();

    }
}

5bab8b7b5691c431940637.png
Please tell me what could be the reason.
Using Java SE 8: openjdk version "1.8.0_181"
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2018-09-26
@AmiAkari

This is a static method, not a constructor. You don't have to newput it in front of him.

K
Kastyan, 2018-09-26
@iSmoke

= DocumentBuilderFactory.newInstance();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question