/**

 *静态导入:是指可以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);

       }

}

 

 

 

 

相关文章:

  • 2021-07-14
  • 2021-08-31
  • 2022-12-23
  • 2021-11-02
  • 2021-06-29
  • 2021-06-18
  • 2021-08-27
猜你喜欢
  • 2021-11-04
  • 2021-11-18
  • 2021-08-20
  • 2021-10-06
  • 2021-08-22
  • 2022-02-16
  • 2021-08-28
相关资源
相似解决方案