compiler errors - I keep getting 'Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 30? -


this edhesive class, , works fine when use eclipse compiler. reason when enter edhesive's compiler, error keeps popping up.

import java.util.scanner;  class main {      public static void main(string[] args) {          scanner scan = new scanner(system.in);          system.out.println("what month born in? (number)");         int month = scan.nextint();          system.out.println("what day? (number)");         int day = scan.nextint();          string[] arraym = {                 "january", "february", "march", "april", "june", "july", "august", "september", "october", "november", "december"         };         string[] arrayd = {                 "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eight", "ninth", "tenth", "eleventh", "twelvth", "thirteenth",                 "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth", "twenty-first",                 "twenty-second", "twenty-third", "twenty-fourth", "twenty-fifth", "twenty-sixth", "twenty-seventh",                 "twenty-ninth", "thirtieth", "thirty-first"         };          system.out.println("your birthday is: " + arraym[month - 1] + " " + arrayd[day - 1]);          if (month == 1) {             if (day >= 1 && day <= 19)                 system.out.println("capricorn");             else if (day >= 20 && day <= 31)                 system.out.println("aquarius");         } else if (month == 2) {             if (day >= 1 && day <= 18)                 system.out.println("aquarius");             else if (day >= 19 && day <= 31)                 system.out.println("pisces");         } else if (month == 3) {             if (day >= 1 && day <= 20)                 system.out.println("pisces");             else if (day >= 21 && day <= 31)                 system.out.println("aries");         } else if (month == 4) {             if (day >= 1 && day <= 21)                 system.out.println("aries");             else if (day >= 22 && day <= 31)                 system.out.println("taurus");         } else if (month == 5) {             if (day >= 1 && day <= 20)                 system.out.println("taurus");             else if (day >= 21 && day <= 31) ;             system.out.println("gemini");         } else if (month == 6) {             if (day >= 1 && day <= 20)                 system.out.println("gemini");             else if (day >= 21 && day <= 31)                 system.out.println("cancer");         } else if (month == 7) {             if (day >= 1 && day <= 22)                 system.out.println("gemini");             else if (day >= 23 && day <= 31)                 system.out.println("leo");         } else if (month == 8) {             if (day >= 1 && day <= 22)                 system.out.println("leo");             else if (day >= 23 && day <= 31)                 system.out.println("virgo");         } else if (month == 9) {             if (day >= 1 && day <= 22)                 system.out.println("virgo");             else if (day >= 1 && day <= 31)                 system.out.println("libra");         } else if (month == 10) {             if (day >= 1 && day <= 22)                 system.out.println("libra");             else if (day >= 23 && day <= 31)                 system.out.println("scorpio");         } else if (month == 11) {             if (day >= 1 && day <= 21)                 system.out.println("scorpio");             else if (day <= 22 && day <= 31)                 system.out.println("sagittarius");         } else if (month == 12) {             if (day >= 1 && day <= 21)                 system.out.println("sagittarius");             else if (day >= 22 && day <= 31)                 system.out.println("capricorn");         } else {             system.out.println("error");         }       } } 

looks "twenty-eighth" missing in arrayd, there 30 elements.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -