调用Math类的静态方法,每次都要写Math点方法。
public static void main(String args)
{
system.out.print(Math.max(3,6));
system.out.print(Math.min(3.6));
}
JDK1.5支持静态导入
import static java.lang.Math.max;
public static void main(String args)
{
system.out.print(max(3,6));
}
当然这样导入就更可以了import static java.lang.Math.*;
本文介绍如何使用JDK1.5的静态导入特性简化Math类方法的调用过程,通过示例展示静态导入前后的代码对比,使读者了解这一特性带来的便利。
521

被折叠的 条评论
为什么被折叠?



