אני לא מצליח להעביר משתנים שמוגדרים לי בclass החיצוני לתוך class שמוגדר לי בתוך הclass החיצוני. הוא רושם לי: Cannot refer to a non-final variable IPAddress inside an inner class defined in a different method
את הודעת השגיאה שהזכרת מקבלים כאשר לדוגמא מנסים לגשת למשתנה לוקאלי של מתודה מתוך אובייקט שמאותחל בתוכה. לדוגמא:
public void outerMethod (int x) { final int copyOfx = x; new Object() { public String toString() { return "x is " + x + " and copyOfx is " + y; //reference to copyOfx is allowed, reference to x is not. } } } }