首页 > 其他 > 详细

JDK5-静态导入

时间:2016-11-01 14:42:57      阅读:114      评论:0      收藏:0      [点我收藏+]

import static

 

1. 导入一个类内所有静态成员

1 import static java.lang.Math.*;
2 
3 public class StaticImport {
4     public static void main(String[] args) {
5         System.out.println(max(2, 3));
6     }
7 }

2. 导入一个静态函数

1 import static java.lang.Math.random;
2 
3 public class StaticImport {
4     public static void main(String[] args) {
5         System.out.println(random());
6     }
7 }

 

JDK5-静态导入

原文:http://www.cnblogs.com/joshua-aw/p/6019045.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!