Java

From miki
Revision as of 15:54, 10 February 2010 by Mip (talk | contribs) (→‎Miscellaneous)
Jump to navigation Jump to search

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.
Eg:
public class MyClass //...
//...
printf ("Class name is %s\n",MyClass.class.getName());