java oop 31 static import

bitcogo·2022년 7월 31일
0

static import문

  • static멤버를 사용할때 클래스 이름을 생략할 수 있게 해준다
import static java.lang.Integer.*;//integer클래스의 모든 static메서드
//import static java.lang.Math.random;
import static java.lang.Math.*;
import static java.lang.System.out;//System.out을 out만으로 참조가능


public class Oop31_StaticImport {

  public static void main(String[] args) {

      System.out.println(Math.random());
      out.println(random());//이렇게 쓰는거 가능하게 해줌
      out.println("Math.PI =" + PI); //이렇게 쓰는거 가능하게 해줌
    //System.out.println("Math.PI =" + Math.PI); 원래는 이렇게
	  }
	}
profile
공부하고 기록하는 블로그

0개의 댓글