< prev index next >

src/java.base/share/classes/java/lang/Class.java

Print this page




 707 
 708     /**
 709      * Returns the  name of the entity (class, interface, array class,
 710      * primitive type, or void) represented by this {@code Class} object,
 711      * as a {@code String}.
 712      *
 713      * <p> If this class object represents a reference type that is not an
 714      * array type then the binary name of the class is returned, as specified
 715      * by
 716      * <cite>The Java&trade; Language Specification</cite>.
 717      *
 718      * <p> If this class object represents a primitive type or void, then the
 719      * name returned is a {@code String} equal to the Java language
 720      * keyword corresponding to the primitive type or void.
 721      *
 722      * <p> If this class object represents a class of arrays, then the internal
 723      * form of the name consists of the name of the element type preceded by
 724      * one or more '{@code [}' characters representing the depth of the array
 725      * nesting.  The encoding of element type names is as follows:
 726      *
 727      * <blockquote><table summary="Element types and encodings">
 728      * <tr><th> Element Type <th> &nbsp;&nbsp;&nbsp; <th> Encoding
 729      * <tr><td> boolean      <td> &nbsp;&nbsp;&nbsp; <td style="text-align:center"> Z
 730      * <tr><td> byte         <td> &nbsp;&nbsp;&nbsp; <td style="text-align:center"> B
 731      * <tr><td> char         <td> &nbsp;&nbsp;&nbsp; <td style="text-align:center"> C




 732      * <tr><td> class or interface
 733      *                       <td> &nbsp;&nbsp;&nbsp; <td style="text-align:center"> L<i>classname</i>;
 734      * <tr><td> double       <td> &nbsp;&nbsp;&nbsp; <td style="text-align:center"> D
 735      * <tr><td> float        <td> &nbsp;&nbsp;&nbsp; <td style="text-align:center"> F
 736      * <tr><td> int          <td> &nbsp;&nbsp;&nbsp; <td style="text-align:center"> I
 737      * <tr><td> long         <td> &nbsp;&nbsp;&nbsp; <td style="text-align:center"> J
 738      * <tr><td> short        <td> &nbsp;&nbsp;&nbsp; <td style="text-align:center"> S

 739      * </table></blockquote>
 740      *
 741      * <p> The class or interface name <i>classname</i> is the binary name of
 742      * the class specified above.
 743      *
 744      * <p> Examples:
 745      * <blockquote><pre>
 746      * String.class.getName()
 747      *     returns "java.lang.String"
 748      * byte.class.getName()
 749      *     returns "byte"
 750      * (new Object[3]).getClass().getName()
 751      *     returns "[Ljava.lang.Object;"
 752      * (new int[3][4][5][6][7][8][9]).getClass().getName()
 753      *     returns "[[[[[[[I"
 754      * </pre></blockquote>
 755      *
 756      * @return  the name of the class or interface
 757      *          represented by this object.
 758      */




 707 
 708     /**
 709      * Returns the  name of the entity (class, interface, array class,
 710      * primitive type, or void) represented by this {@code Class} object,
 711      * as a {@code String}.
 712      *
 713      * <p> If this class object represents a reference type that is not an
 714      * array type then the binary name of the class is returned, as specified
 715      * by
 716      * <cite>The Java&trade; Language Specification</cite>.
 717      *
 718      * <p> If this class object represents a primitive type or void, then the
 719      * name returned is a {@code String} equal to the Java language
 720      * keyword corresponding to the primitive type or void.
 721      *
 722      * <p> If this class object represents a class of arrays, then the internal
 723      * form of the name consists of the name of the element type preceded by
 724      * one or more '{@code [}' characters representing the depth of the array
 725      * nesting.  The encoding of element type names is as follows:
 726      *
 727      * <blockquote><table>
 728      * <caption style="display:none">Element types and encodings</caption>
 729      * <thead>
 730      * <tr><th style="padding-right:3em;"> Element Type <th> Encoding
 731      * </thead>
 732      * <tbody>
 733      * <tr><td> boolean      <td style="text-align:center"> Z
 734      * <tr><td> byte         <td style="text-align:center"> B
 735      * <tr><td> char         <td style="text-align:center"> C
 736      * <tr><td> class or interface
 737      *                       <td style="text-align:center"> L<i>classname</i>;
 738      * <tr><td> double       <td style="text-align:center"> D
 739      * <tr><td> float        <td style="text-align:center"> F
 740      * <tr><td> int          <td style="text-align:center"> I
 741      * <tr><td> long         <td style="text-align:center"> J
 742      * <tr><td> short        <td style="text-align:center"> S
 743      * </tbody>
 744      * </table></blockquote>
 745      *
 746      * <p> The class or interface name <i>classname</i> is the binary name of
 747      * the class specified above.
 748      *
 749      * <p> Examples:
 750      * <blockquote><pre>
 751      * String.class.getName()
 752      *     returns "java.lang.String"
 753      * byte.class.getName()
 754      *     returns "byte"
 755      * (new Object[3]).getClass().getName()
 756      *     returns "[Ljava.lang.Object;"
 757      * (new int[3][4][5][6][7][8][9]).getClass().getName()
 758      *     returns "[[[[[[[I"
 759      * </pre></blockquote>
 760      *
 761      * @return  the name of the class or interface
 762      *          represented by this object.
 763      */


< prev index next >