以下のクラスでは、次の行でコンパイル エラーが発生します println("Hello World!");
: The method println(String) is undefined for the type StaticImport
:
import static java.lang.Math.*;
import static java.lang.System.*;
public class StaticImport {
public static void main(String[] args) {
println("Hello World!");
out.println("Considering a circle with a diameter of 5 cm, it has:");
out.println("A circumference of " + (PI * 5) + " cm");
out.println("And an area of " + (PI * pow(2.5,2)) + " sq. cm");
}
}
メソッド名 'out' を使用する必要がある println メソッドとは異なり、 pow を明示的にインポートせずに java.lang.Math で pow メソッドにアクセスできるのはなぜですか?