Hi everyone! I am quite new to JAVA but I know most of the basics, especially when it comes to language syntax. I was reading some tutorial where I found the following function:
class SomeClass{...
dlframe.addWindowListener(new WindowAdapter() //<--This is the WEIRD part
{ // Opens addWindowListener method
public void windowClosing(WindowEvent e)
{ // Opens windowClosing method
System.exit(0);
} // Closes windowClosing method
}); // Closes addWindowListener method
}//closes class
Instead of this function written like the following:
class SomeClass{...
dlframe.addWindowListener(new WindowAdapter()) //<--This is how I thought it should be on the first place;
{ // Opens addWindowListener method
public void windowClosing(WindowEvent e)
{ // Opens windowClosing method
System.exit(0);
} // Closes windowClosing method
}; // Closes addWindowListener method
}//closes class
I couldn't find the following syntax in the language specification
object.method(parameters {method body});
Instead I only found syntax like this:
object.method(parameters){method body};
But the funniest thing is that the syntax above works just fine and doesn't issue any compiler error messages. Could anyone please unconfuse me...
? Thank you.