public class EventNotifier ... {private InterestingEvent ie;private boolean somethingHappened;//Delphi中的写法//property OnEvent : TOnEvent read FOnEvent write FOnEvent;public EventNotifier(InterestingEvent event) ...{ this.ie = event; somethingHappened = true;}//Delphi中的写法//if assigned(FOnEvent) then//FOnEvent(self,StrLog);public void doWork() ...{ if (somethingHappened) ...{ ie.interestingEvent(); }}//public static void main(String[] argc)...{ CallMe cm= new CallMe(); EventNotifier ev = new EventNotifier(cm); ev.doWork();}} // 回调函数要用到的接口 interface InterestingEvent ... { public void interestingEvent();} // 要实现调用函数,就要实现回 调函数接口(InterestingEvent ) class CallMe implements InterestingEvent ... {private EventNotifier en;public CallMe() ...{ en = new EventNotifier(this);}public void interestingEvent() ...{ System.out.println("ddd");}}