zoukankan      html  css  js  c++  java
  • JDK5.0新特性系列4.静态导入

    /**

     *静态导入:是指可以import类的静态方法和静态变量,在使用时,无须指定类名,

     *         便可以使用这些被import的静态方法和静态变量,这就是静态导入

     *import语句时,可以定位到一个静态方法或静态变量(以前是定位到类)

     *可以使用通配符(*)代表导入该类的所有静态方法和静态变量

     *不允许静态方法和静态变量出现重名的情况

    */

    import static java.lang.Math.max;  //导入了Mathmax方法

    import static java.lang.Math.min;  //导入了Mathmin方法

    import static java.lang.Integer.*; //导入了Integer的所有静态方法和静态属性

    public class StaticImport {

           public static void main(String[] args){

                  //通过静态导入使用Math的静态方法

                  System.out.println(max(5,10));

                  System.out.println(min(5,10));

                  //通过静态导入使用Integer的静态方法

                  System.out.println(parseInt("55544555"));

                  System.out.println(toBinaryString(2354));

                  //通过静态导入使用Integer的静态属性

                  System.out.println(MAX_VALUE);

                  System.out.println(MIN_VALUE);

           }

    }

    作者:Taven.李锡远
    出处:http://taven.cnblogs.com/
    本文版权归作者和博客园共有,欢迎转载。但必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。博主QQ/微信: 17020415 (QQ和微信同号哦^_^)
  • 相关阅读:
    Eclipse对printf()不能输出到控制台的解决方法
    Eclipse launch failed.Binary not found解决方案
    Windows 7中使用Eclipse 使用CDT and WinGW 开发C/C++(转载)
    assets
    方法对头,报表模板维护其实很简单
    刷机包各个文件都是啥
    开机logo切换逻辑深入研究
    不同分辨率的LCM进行兼容
    SD卡驱动分析(二)
    SD卡驱动分析(一)
  • 原文地址:https://www.cnblogs.com/taven/p/2291456.html
Copyright © 2011-2022 走看看