JDK 1.5 Characteristics Example 6 - StaticImport

xiaoxiao2021-03-06  85

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);

}

}

转载请注明原文地址:https://www.9cbs.com/read-108564.html

New Post(0)