Programming Languages, Java, Software Development, Software Engineering, Software Architecture.
String lastName = "Doe"; }; example24.firstName = "John"; // it works In the above example, we can access the variable of this Anonymous class. This is only possible using ‘var’ because it won’t work without it. Object example25 = new Object() { String firstName = "John"; String lastName = "Doe";