Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package testpackage;
- public interface MyInterface<T> {
- T func(T t);
- }
- class Driver
- {
- public static void main(String[] args) {
- MyInterface<String> myInterface = (str)->
- {
- String result = "";
- for(int i=str.length()-1;i>=0;i--)
- {
- result+=str.charAt(i);
- }
- return result;
- };
- MyInterface< Integer> myInterface2 = (a)->
- {
- int result = 1;
- for(int i=2;i<=a;i++)
- {
- result*=i;
- }
- return result;
- };
- System.out.println(myInterface.func("Utshaw"));
- System.out.println(myInterface2.func(5));
- Integer[] nums = {1,2,3,4,5,12345};
- System.out.println(GenMethDemo.isIn(12345, nums));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement