Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static int getDaysInMonth(int month, int year) {
        switch (month) {
        default:
            throw new IllegalArgumentException("Invalid Month");
        case 0:
        case 2:
        case 4:
        case 6:
        case 7:
        case 9:
        case 11:
            return 31;
        case 3:
        case 5:
        case 8:
        case 10:
            return 30;
        case 1:
            if (year % 4 == 0)
                return 29;
            return 28;
        }
    }
}