My array looks something like this
String[] dayNames = new String[DAYS_IN_WEEK];
dayNames[0] = "Sunday";
dayNames[1] = "Monday";
dayNames[2] = "Tuesday";
dayNames[3] = "Wednesday";
dayNames[4] = "Thursday";
dayNames[5] = "Friday";
dayNames[6] = "Saturday";
I need to print the index of the array using a method findDay.
so if "Saturday" was selected, i would need 6 to be returned.
Thanks for your time =D P.s. No answers please? Just suggestions =)
UPPDATE**
my array will not compile. This is exactly what i have:
private static final int DAYS_IN_WEEK = 7;
String[] dayNames;
dayNames = new String[DAYS_IN_WEEK]
// Declare an array of Strings named dayNames
dayNames[0] = "Sunday";
dayNames[1] = "Monday";
dayNames[2] = "Tuesday";
dayNames[3] = "Wednesday";
dayNames[4] = "Thursday";
dayNames[5] = "Friday";
dayNames[6] = "Saturday";
and I get multiple errors starting with:
Weekdays.java:12: error: <identifier> expected
dayNames = new String[DAYS_IN_WEEK]
I don't understand why. I literally copied the EXACT format from http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html