mercredi 27 mai 2015

Multiple IF statement; Months

I know this might be a really stupid question and I know I should import a class for this, but I would really like to know what is the mistake in the following code. I am taking Java class and I would really like to get some help.

int m = 1;
 String month;
        if(int m = 1){ 
           month = "January";
        }else if(int m = 2){ 
           month  = "February";   
        }else if(int m = 3){ 
           month  = "March"; 
        }else if(int m = 4){ 
           month  = "April"; 
        }else if(int m = 5){ 
           month  = "May"; 
        }else if(int m = 6){ 
           month  = "June"; 
        }else if(int m = 7){ 
           month  = "July";
        }else if(int m = 8){ 
           month  = "August";
        }else if(int m = 9){ 
           month  = "September"; 
        }else if(int m = 10){ 
           month  = "October"; 
        }else if(int m = 11){ 
           month  = "November"; 
        }else if(int m = 12){ 
           month  = "December"; 
        }

I keep getting

*./Root/Main.java:16: error: '.class' expected
        if(int m = 1){ 
               ^*

Is the problem with the string name?

Aucun commentaire:

Enregistrer un commentaire