1

I am new to java 8 and trying this. i have an interface

public interface CurrencyRateDao{
    Double getCurrencyRate(String srcCur,String tarCur, int month);
}

Accessing using it this way :

CurrencyRateDao currencyRateDao = new CurrencyRateDaoImpl();
Double rate = ('USD','INR',1) -> currencyRateDao::getCurrencyRate;

Giving an error:

target type of this expression must be a functional interface.

Please suggest what is wrong with above code

1 Answer 1

3

You simply need

Double rate = currencyRateDao.getCurrencyRate("USD", "INR", 1);

If you were to represent the interface as a lambda, it would look like :

CurrencyRateDao currencyRateDao = (srcCur, tarCur, month) -> Double.MAX_VALUE;
// accepts three arguments and returns a Double value
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.