|  
   
定义一个包含常量的接口。即我们熟知的反模式 常量接口 
Constants.java 
  
package maoxiang.examples.jdk15.staticimport; 
  
/** 
* @author 毛翔 
* 
* 常量接口 
*/ 
public interface Constants { 
  
public static float PI = 3.1415926f; 
} 
  
使用常量接口 Demo.java 
  
  
package maoxiang.examples.jdk15.staticimport; 
  
import static maoxiang.examples.jdk15.staticimport.Constants.PI;  
/** 
* @author 毛翔 
* 
*   
*/ 
public class Demo { 
  
public static void main(String[] args) { 
Test1(); 
} 
public static void Test1(){ 
System.out.print(PI); 
} 
} 
   
 
  |