且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jdk1.5新特性1之静态导入

更新时间:2022-07-01 09:28:57

调用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.*;

本文转自IT徐胖子的专栏博客51CTO博客,原文链接http://blog.51cto.com/woshixy/1059208如需转载请自行联系原作者


woshixuye111