How to specify lambda expression in JAVA when I have two same name method?

s gong :

How to specify lambda expression in JAVA when I have two same name method?

JAVA8

package com.gsy;  

import java.io.BufferedReader;  
import java.io.IOException;  
import java.io.InputStream;  
import java.io.InputStreamReader;  
import java.net.URL;  
import java.util.ArrayList;  
import java.util.Collections;  
import java.util.Comparator;  
import java.util.Date;  
import java.util.ResourceBundle;  

public class EmailProperty {  
    public static void main(String args[]) {  


    }  
    interface qqq{  
        int a(int a);  
    }  
    interface ppp{  
        int a(int b);  
    }  
    class test{  
        int a;  
        int b;  
        int testa(int a,int b,qqq qqq){  
            return 1;  
        }  
        int testa(int a,int b,ppp ppp){  
            return 1;  
        }  
    }  
    public EmailProperty() {  
        test aaa = new test();  
        aaa.a = 1;  
        aaa.b = 2;  

        aaa.testa(1, 2,new ppp() {  

            @Override  
            public int a(int b) {  
                // TODO Auto-generated method stub  
                return 0;  
            }  
        });  
        aaa.testa(1, 2,???);  
    }  
}  

what I can write in ???,and don`t need to use Anonymous function.I cant find any method to specify ppp or qqq when I use lambda.

ernest_k :

You can cast:

aaa.testa(1, 2, (qqq) i -> 0); 
aaa.testa(1, 2, (ppp) i -> 0);  

Or use a variable:

qqq q = i -> 0;
aaa.testa(1, 2, q);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=77001&siteId=1