jeudi 5 novembre 2020

how can i use enum with if else satement

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor. */ package enums;

import javax.swing.JOptionPane;

/** *

  • @author pedev */ public class Enums {

enum months{ JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OKT, NOV,DEC
} public static void main(String[] args) {

        months year[] = months.values();
        for(months m : year){
            System.out.println(m);
            
            String BirthMonth;
       BirthMonth = JOptionPane.showInputDialog("Enter the first free letters of youre birth month");
            
            if(BirthMonth == months.JAN){
                System.out.println("");
                
            }else{
                if(BirthMonth == months.FEB){
                    System.out.println("");
                }
            }
        }
        
}

}

Aucun commentaire:

Enregistrer un commentaire