Define an interface that contains constants. That is, we are well known to the anti-mode constant interface
Constants.java
Package maoxiang.examples.jdk15.staticImport;
/ **
* @Author Mao Xiang
*
* Constant interface
* /
Public interface constants {
PUBLIC STATIC FLOAT PI = 3.1415926F;
}
Using constant interface Demo.java
Package maoxiang.examples.jdk15.staticImport;
Import static maoxiang.examples.jdk15.staticImport.constants.pi;
/ **
* @Author Mao Xiang
*
*
* /
Public class demo {
Public static void main (String [] args) {
TEST1 ();
}
Public static void test1 () {
System.out.print (pi);
}
}