< prev index next >

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

Print this page




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




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


< prev index next >