标签:class blog code java get 2014
直接上菜 /*接口类*/ public interface MsgListener{ public void afterMsgRecived(String msgData); } /*工具类*/ public class Tools{ public static void getMsgData(String reciver,MsgListener listener){ reciver+=reciver; //关键的来了 listener.afterMsgRecived(reciver); } } //调用 public static void main(String[] args){ String reciver="JACK THE REAPER"; //调用 Tools.getMsgData(reciver,new MsgListener(){ @override public void afterMsgRecived(String msgData){ System.out.println(msgData); } }); } 最后,yes,yes,你会看到控制台输出:"JACK THE REAPERJACK THE REAPER";
标签:class blog code java get 2014
原文地址:http://blog.csdn.net/lovingshu/article/details/30079797