{"rsdb":{"rid":"395128","subhead":"","postdate":"0","aid":"272508","fid":"54","uid":"1","topic":"1","content":"

interface Eatable {
    void eat();
}<\/p>

interface Flyable {
    void fly(String s);
}<\/p>

interface Addable {
    int add(int a, int b);
}<\/p>

public class LambdaDemo {
    \/\/\u8c03\u7528\u8be5\u65b9\u6cd5\u9700\u8981Eatable\u5bf9\u8c61
    public void eat(Eatable e) {
        System.out.println(e);
        e.eat();
    }
 \/\/\u8c03\u7528\u8be5\u65b9\u6cd5\u9700\u8981Flyable\u5bf9\u8c61
    public void drive(Flyable f) {
        System.out.println("\u6211\u6b63\u5728\u9a7e\u9a76\uff1a" + f);
        f.fly("\u5927\u6674\u5929");
    }
 \/\/\u8c03\u7528\u8be5\u65b9\u6cd5\u9700\u8981Addble\u5bf9\u8c61
    public void test(Addable a) {
        System.out.println("1\u52a01\u7b49\u4e8e\uff1a" + a.add(1, 1));
    }<\/p>

    public static void main(String[] args) {
        LambdaDemo ld = new LambdaDemo();
        ld.eat(() -> System.out.println("\u5403\u82f9\u679c"));
        ld.drive(s -> {
            System.out.println("\u4eca\u5929\u5929\u6c14\u662f\uff1a" + s);
            System.out.println("\u5f00\u8f66\u5f88\u723d");
        });
        ld.test((a, b) -> a + b);
    }
}<\/p>

\u4ece\u4e0a\u9762\u8bed\u6cd5\u683c\u5f0f\u4e2d\u53ef\u4ee5\u770b\u51fa\uff0cLambda\u8868\u8fbe\u5f0f\u5c31\u76f8\u5f53\u4e8e\u4e00\u4e2a\u533f\u540d\u65b9\u6cd5\u3002\u5b83\u7531\u4e09\u90e8\u5206\u7ec4\u6210\uff1a<\/p>

\u7701\u7565\u5199\u6cd5\uff1a<\/p>

\u4ece\u4ee3\u7801\u4e2d\u8fd8\u53ef\u4ee5\u770b\u51fa\uff0cLambda\u8868\u8fbe\u5f0f\u5b9e\u9645\u4e0a\u5c06\u4f1a\u88ab\u5f53\u6210\u4e00\u4e2a\u201c\u4efb\u610f\u7c7b\u578b\u201d\u7684\u5bf9\u8c61\uff0c\u9700\u8981\u5f53\u6210\u4f55\u79cd\u7c7b\u578b\uff0c\u53d6\u51b3\u4e8e\u8fd0\u884c\u73af\u5883\u7684\u9700\u8981\u3002<\/p>

? Lambda\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u4e5f\u88ab\u79f0\u4e3a\u201c\u76ee\u6807\u7c7b\u578b\u201d\uff0cLambda\u8868\u8fbe\u5f0f\u7684\u76ee\u6807\u7c7b\u578b\u5fc5\u987b\u662f\u201c\u51fd\u6570\u5f0f\u63a5\u53e3\u201d\u3002\u51fd\u6570\u5f0f\u63a5\u53e3\u4ee3\u8868\u53ea\u5305\u542b\u4e00\u4e2a\u62bd\u8c61\u65b9\u6cd5\u7684\u63a5\u53e3\u3002\u51fd\u6570\u5f0f\u63a5\u53e3\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u9ed8\u8ba4\u65b9\u6cd5\u3001\u7c7b\u65b9\u6cd5\uff0c\u4f46\u53ea\u80fd\u58f0\u660e\u4e00\u4e2a\u62bd\u8c61\u65b9\u6cd5\u3002<\/p>

? Lambda\u8868\u8fbe\u5f0f\u9650\u5236\uff1a<\/p>

\u5176\u5b9e\uff0cLambda\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u5c31\u662f\u88ab\u5f53\u6210\u5bf9\u8c61\uff0c\u6240\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u5b8c\u5168\u53ef\u4ee5\u4f7f\u7528Lambda\u8868\u8fbe\u5f0f\u8fdb\u884c\u8d4b\u503c\u3002<\/p>

? \u65b9\u6cd5\u5f15\u7528\u548c\u6784\u9020\u5668\u5f15\u7528\u90fd\u9700\u8981\u4f7f\u7528\u4e24\u4e2a\u82f1\u6587\u5192\u53f7\u3002\u5982\u8868\uff1a<\/p>

\u4e3e\u4e2a\u4f8b\u5b50<\/strong>\uff1a<\/p>

\u76f8\u540c\u70b9\uff1a<\/p>

\u533a\u522b\uff1a<\/p>

\u6838\u5fc3\u63a5\u53e3\u5927\u81f4\u5206\u4e3a\u4ee5\u4e0b\u56db\u7c7b\uff1a<\/p>","orderid":"0","title":"\u521d\u8bc6Lambda\u8868\u8fbe\u5f0f","smalltitle":"","mid":"0","fname":"linux\u7f16\u7a0b\u57fa\u7840","special_id":"0","bak_id":"0","info":"0","hits":"602","pages":"1","comments":"0","posttime":"2023-07-26 08:18:32","list":"1690330712","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u521d\u8bc6<\/A> Lambda<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"119.59.235.169","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"\u521d\u8bc6Lambda\u8868\u8fbe\u5f0f","lastview":"1714284695","digg_num":"746","digg_time":"1714133053","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}