Static Imports

1. Static Imports 개요

Static Class, Static 변수, enum값 등을 사용할 때 정적 Import를 사용해서 타이핑을 적게할 수 있다.
이름이 중복될 가능성이 많고, 가독성을 감안하면 쓰지 않는것이 좋음

2. 선언방법


import static java.lang.Math.*;


3. 예제

- 기존코드


import java.lang.Math;
public class Before_StaticImportTest{
	public static void main(String[] args){
		System.out.println("sqrt:"+ Math.sqrt(2.0));
	}
}

- JAVA 5.0 코드


import static java.lang.Math.*;
public class After_StaticImportTest{
	public static void main(String[] args){
		System.out.println("sqrt:"+ sqrt(2.0));
	}
}