Java: Difference between revisions

From miki
Jump to navigation Jump to search
(Created page with '== Sample Program == <source lang="java"> Class Test { public static void main(String[] args) { for (int i = 0; i < args.length; i++) System.out.print(i = 0 ? args[i]…')
 
(Miscellaneous)
Line 9: Line 9:
}
}
</source>
</source>

== Miscellaneous ==
;[http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#251530 Class Literal]
:A class literal is an expression consisting of the name of a class, interface, array, or primitive type followed by a <code>.</code> and the token <code>class</code>. The type of a class literal is <code>Class</code>. It evaluates to the Class object for the named type (or for void) as defined by the defining class loader of the class of the current instance.

Revision as of 15:55, 9 February 2010

Sample Program

Class Test {
  public static void main(String[] args) {
    for (int i = 0; i < args.length; i++)
      System.out.print(i = 0 ? args[i] : " " + args[i]);
    System.out.println();
  }
}

Miscellaneous

Class Literal
A class literal is an expression consisting of the name of a class, interface, array, or primitive type followed by a . and the token class. The type of a class literal is Class. It evaluates to the Class object for the named type (or for void) as defined by the defining class loader of the class of the current instance.