其实成杰兄上面的也是正确的,因为总共有这么多类拥有newInstance()方法,
com.sun.jdi.ArrayType.newInstance(int)
com.sun.jdi.ClassType.newInstance(com.sun.jdi.ThreadReference, com.sun.jdi.Method, java.util.List, int)
java.lang.Class.newInstance()
java.lang.reflect.Array.newInstance(java.lang.Class, int)
java.lang.reflect.Array.newInstance(java.lang.Class, int[])
java.lang.reflect.Constructor.newInstance(java.lang.Object...)
java.net.URLClassLoader.newInstance(java.net.URL[])
java.net.URLClassLoader.newInstance(java.net.URL[], java.lang.ClassLoader)
java.rmi.activation.ActivationGroup_Stub.newInstance(java.rmi.activation.ActivationID, java.rmi.activation.ActivationDesc)
java.rmi.activation.ActivationInstantiator.newInstance(java.rmi.activation.ActivationID, java.rmi.activation.ActivationDesc)
java.security.KeyStore.Builder.newInstance(java.lang.String, java.security.Provider, java.io.File, java.security.KeyStore.ProtectionParameter)
java.security.KeyStore.Builder.newInstance(java.lang.String, java.security.Provider, java.security.KeyStore.ProtectionParameter)
java.security.KeyStore.Builder.newInstance(java.security.KeyStore, java.security.KeyStore.ProtectionParameter)
java.security.Provider.Service.newInstance(java.lang.Object)
javax.naming.ldap.InitialLdapContext.newInstance(javax.naming.ldap.Control[])
javax.naming.ldap.LdapContext.newInstance(javax.naming.ldap.Control[])
javax.xml.datatype.DatatypeFactory.newInstance()
javax.xml.parsers.DocumentBuilderFactory.newInstance()
javax.xml.parsers.SAXParserFactory.newInstance()
javax.xml.transform.TransformerFactory.newInstance()
javax.xml.validation.SchemaFactory.newInstance(java.lang.String)
javax.xml.xpath.XPathFactory.newInstance()
javax.xml.xpath.XPathFactory.newInstance(java.lang.String)
org.w3c.dom.bootstrap.DOMImplementationRegistry.newInstance()
org.w3c.dom.bootstrap.DOMImplementationRegistry.newInstance()
我刚才说的是:
java.lang.Class.newInstance()
其中具体的方法得要靠楼主自己摸索使用了 |