June 21, 2022

How to use function interface in your application | simple example for lamba expression | Interview questions

Created a simple functional Interface

/**
 * @author Stock market swing trad
 *
 */
@functionInterface
public interface InitialStatus {
public String set();

}


Implementing the function Interface


    InitialValue soldCountInitialValue = () -> Long.valueOf(0);
    InitialValue quantityInitialValue = () -> Long.valueOf(0);
    InitialValue taxInitialValue = () -> Long.valueOf(5);
    InitialValue ratingInitialValue = () -> Long.valueOf(1);
    InitialValue ratingInitialCount = () -> Long.valueOf(1);


Using the variables

itemObj.setSoldCount(soldCountInitialValue.set());

No comments:

Post a Comment

Your feedback may help others !!!

Facebook comments