Friday, August 20, 2010

Static imports in java 1.5

Static imports allow the static items of another class to be referenced without qualification.

package com;

import static com.StaticImportMe.doStaticImportOnMe;

public class StaticImport {

 /**
  * @param args
  */
 public static void main(String[] args) {
  /**
   * No need to use StaticImportMe.doStaticImportOnMe(args[0]); 
   */
  doStaticImportOnMe(args[0]);
 }

}

No comments: