Schatzi Java Online Manual & Tutorial & Lecture

 1 À͸í Ŭ·¡½ºanonymous class
 

Áö¿ª Ŭ·¡½ºÀÇ º¯ÇüÀ¸·Î ÇϳªÀÇ ½Ä ³»ºÎ¿¡¼­ Ŭ·¡½ºÀÇ ¼±¾ð°ú °´Ã¼ »ý¼ºÀÌ µ¿½Ã¿¡ ¹ß»ýÇÏ´Â ³»ºÎ Ŭ·¡½ºÀÌ´Ù.

interface hasFoo
{    
      void foo();
}

class Top
{    
      int i = 33;
      void bar() 
      {    
            (new hasFoo(){   
                 int k = i;
                 public void foo() {}}).foo();
      }
}






Copyright ¨Ï 1999-2000 Schatzi. All rights reserved.
http://www.jabook.org
http://schatzi.konkuk.ac.kr