Hi! I'm a newbie in Java programming, and I'm learning from some open-source projects now. I've just came across a question: what does this block mean? I got surprised by the method defined with another method, which is rarely seen in C++. Can someone explain a little for me? Thanks a lot!

P.S.: Here we see a 'new' operation that creates an Authenticator object, but I don't understand what the block means that follows the new operation. It seems to have defined a 'getPasswordAuthentication()' method there, but why it is defined here, not in the class?

Authenticator.setDefault
			(
				new Authenticator()
				{
					protected PasswordAuthentication getPasswordAuthentication()
					{
						PasswordAuthentication passwordAuthentication = null;
 
						if(this.getRequestorType() == Authenticator.RequestorType.PROXY)
						{
							if(this.getRequestingURL().getProtocol().equalsIgnoreCase("HTTP") == true)
							{
								passwordAuthentication = new PasswordAuthentication(APJP.APJP_HTTP_PROXY_SERVER_USERNAME, APJP.APJP_HTTP_PROXY_SERVER_PASSWORD.toCharArray());
							}
							else
							{
								if(this.getRequestingURL().getProtocol().equalsIgnoreCase("HTTPS") == true)
								{
									passwordAuthentication = new PasswordAuthentication(APJP.APJP_HTTPS_PROXY_SERVER_USERNAME, APJP.APJP_HTTPS_PROXY_SERVER_PASSWORD.toCharArray());
								}
							}
						}
 
						return passwordAuthentication;
					}
				}
			);