I have code in this format:
String test = "test";
objectContainer.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent event) {
// Prints "test"
System.out.println(test);
}
});
I have read in many examples online that you are unable to access such an outside variable normally. Am I using some sort of bad practice? Is my java version outdated?