美文网首页
静态导入包

静态导入包

作者: 哈迪斯Java | 来源:发表于2021-09-25 14:03 被阅读0次

package oop.Demon7;

import static java.lang.Math.random;//静态导入包
import static java.lang.Math.PI;

public class Test {

public static void main(String[] args) {
    System.out.println(random());
    System.out.println(PI);
}

}

==================
如果在输入过程中,觉得Math.random输入麻烦,可以在前面inport static java.Math.random。
类似的其他类型也可以使用静态导入包,方便使用~~~

相关文章

网友评论

      本文标题:静态导入包

      本文链接:https://www.haomeiwen.com/subject/blctnltx.html