REMEMBER JAVA

MINTE9
2REMEMBER




IMPORT STATIC

p107 In some cases you use heavily constants from a utilitiy class. You can use import static to avoid qualifying with the class name.
 RunCode
import static java.lang.Math.PI; // Look Here
import static java.lang.Math.E;

class App {

    public static void main(String[] args) {

        System.out.println(PI); // 3.141592653589793
        System.out.println(E); // 2.718281828459045
    }
}
... 8 lines
˄˄˄
! It can have negative impact on readabilty and testability. You dump potentialy large classes into your namespace.
 RunCode
import static java.lang.Math.*; // Look Here

class App {

    public static void main(String[] args) {

        System.out.println(PI);
        System.out.println(E);
    }
}
... 7 lines
˄˄˄

Questions    
No. 61   Enum
CARD
60
63

        A B C D E F
🔔
1/1