I have two classes
I am not sure why this is erroring. In eclipse there are no red underlines.
Main:
package com.example; public class Main { public static void main(String[] args) { Week myWeek = new Week(Week.days.FRIDAY); System.out.println(myWeek.Today.toString()); } } Week:
package com.example; public class Week { public static enum days { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } static final days[] order = { days.SUNDAY, days.MONDAY, days.TUESDAY, days.WEDNESDAY, days.THURSDAY, days.FRIDAY, days.SATURDAY }; days Today; Week(days toSetTo){ @SuppressWarnings("unused") days Today = toSetTo; } } the error is on Main.java:6
ALL_CAPS, variables incamelCase.Today, one variable is local to the constructor, and the other is the instance variable. You should always usethis.varNameto reference an instance variable.