<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="extensibility" page="functions" subpage="constructors"/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: Calling Java Constructors</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Calling Java Constructors"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Calling Java Constructors</h1>
      <p><b>Java constructors</b> are called by using the function named <code>new()</code>. 
If there are several constructors, then again
the system tries to find the one that is the best fit, according to the types of the supplied arguments. The result
 of calling <code>new()</code> is an XPath value whose type is denoted by a QName whose local name
 is the actual Java class (for example <code>java.sql.Connection</code> or <code>java.util.List</code>)
 and whose namespace
 URI is <code>http://saxon.sf.net/java-type</code> (conventional prefix <code>class</code>). Any '$'
 characters in the class name are replaced by '-' characters in the QName.
 The only things that can be done with a wrapped Java Object
 are to assign it to a variable, to pass it to an extension function, and to convert it to a string, number,
 or boolean, using the rules given below.</p>
      <p>The use of external object types in namespace <code>http://saxon.sf.net/java-type</code> reflects the
Java type hierarchy. For example, if a variable is declared to accept a type of <code>jt:java.util.List</code>, then
a value of type <code>jt:java.util.ArrayList</code> will be accepted, but a value of type <code>jt:java.util.HashMap</code>
will not.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="instance-methods.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>