2013년 9월 2일 월요일

자바에서 윤년 구하는 메소드 [출처] 오라클자바커뮤니티 - http://www.oraclejavanew.kr/bbs/board.php?bo_table=LecJava&wr_id=434

자바에서 윤년 구하는 메소드

public class IfLeapYears {

        public static void chkYun(int year) {
                boolean isYun=false;
               
                if( (0 == (year % 4) &&
                         0 != (year %100)) ||
                         0 == year%400 ){
                        isYun = true;
                }else{
                        isYun = false;
                }
                       
                if(isYun){
                        System.out.println(year+"는 윤년. ");
                }else{
                        System.out.println(year+"는 윤년이 아님.");
                }               
        }               
}

오라클자바커뮤니티 추천 실무 강좌


댓글 없음:

댓글 쓰기