关于:XX.getClass().getName();
给你getName()方法的源码,看看自己能明白点什么不(你想要的答案 方法注释的举例中就有,别忘了亲,java是开源的,其他的THML样式和看不懂的要学会忽略)- /**
- * Returns the name of the entity (class, interface, array class,
- * primitive type, or void) represented by this <tt>Class</tt> object,
- * as a <tt>String</tt>.
- *
- * <p> If this class object represents a reference type that is not an
- * array type then the binary name of the class is returned, as specified
- * by the Java Language Specification, Second Edition.
- *
- * <p> If this class object represents a primitive type or void, then the
- * name returned is a <tt>String</tt> equal to the Java language
- * keyword corresponding to the primitive type or void.
- *
- * <p> If this class object represents a class of arrays, then the internal
- * form of the name consists of the name of the element type preceded by
- * one or more '<tt>[</tt>' characters representing the depth of the array
- * nesting. The encoding of element type names is as follows:
- *
- * <blockquote><table summary="Element types and encodings">
- * <tr><th> Element Type <th> <th> Encoding
- * <tr><td> boolean <td> <td align=center> Z
- * <tr><td> byte <td> <td align=center> B
- * <tr><td> char <td> <td align=center> C
- * <tr><td> class or interface
- * <td> <td align=center> L<i>classname</i>;
- * <tr><td> double <td> <td align=center> D
- * <tr><td> float <td> <td align=center> F
- * <tr><td> int <td> <td align=center> I
- * <tr><td> long <td> <td align=center> J
- * <tr><td> short <td> <td align=center> S
- * </table></blockquote>
- *
- * <p> The class or interface name <i>classname</i> is the binary name of
- * the class specified above.
- *
- * <p> Examples:
- * <blockquote><pre>
- * String.class.getName()
- * returns "java.lang.String"
- * byte.class.getName()
- * returns "byte"
- * (new Object[3]).getClass().getName()
- * returns "[Ljava.lang.Object;"
- * (new int[3][4][5][6][7][8][9]).getClass().getName()
- * returns "[[[[[[[I"
- * </pre></blockquote>
- *
- * @return the name of the class or interface
- * represented by this object.
- */
- public String getName() {
- if (name == null)
- name = getName0();
- return name;
- }
复制代码 |