Static import (Know)
Format: import static package name. Class Name. Method name (attribute name);
You can use this static member in a class without the class name. Simply write the method name or the property name as you like.
Static Import Disadvantages:
1. Code readability decreased.
2. Due to the repetition of the method name, static import will error in some specific cases.
---------------------------
PackageCn.itcast.staticdemo;Importjava.util.Arrays;Importorg.junit.Test;Import Staticjava.util.arrays.*;Import Staticjava.lang.math.*;//Static Import//Static Import Public classDemo {@Test Public voidFun () {//Double d = math.random ();//get a random number between 0-1 contains 0 does not contain 1 DoubleD =random (); System.out.println (d); System.out.println (PI); } @Test Public voidfun1 () {int[] arr = {1, 2, 3 }; String s=arrays.tostring (arr); //String s = toString (arr);//repeat with the ToString method in the object class. System.out.println (s); }}
JDK5.0 new Features-static import