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:

PHP Code:
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:


PHP Code:
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
PHP Code:

object
.method(parameters {method body}); 
Instead I only found syntax like this:
PHP Code:

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.