반응형
Math 함수 이용하기
public class MathTest {
public static void main(String[] args) {
// static final public
// 변수이름 ; 소문자 명사
// final 변수 (=상수) 이름 ; 대문자 구성 ; read-only만 가능
System.out.println("원주율= "+Math.PI);
System.out.println("자연로그 = "+Math.E);
System.out.println("첫번째 난수 = "+(int)((Math.random())*100));
System.out.println("두번째 난수 = "+(int)((Math.random())*100));
System.out.println("-100의 절대값 = "+Math.abs(-10.3));
System.out.println("2의 3제곱근 값 = "+Math.pow(2,3));
System.out.println("루트 3의 값 = "+Math.sqrt(3));
System.out.println("반올림 값 = "+Math.round(3.242345));
}
}
반응형
'콩's EDUCATION > 콩's JAVA_RUN' 카테고리의 다른 글
Vector 저장데이터, 총크기, 데이터 조회 (0) | 2014.05.20 |
---|---|
WRAPPER 클래스 Integer (0) | 2014.05.19 |
String 메소드 활용 (0) | 2014.05.19 |
Clone (0) | 2014.05.19 |
toString (0) | 2014.05.19 |