Commit 29fa3dfc authored by Harshitha Sai Muppala's avatar Harshitha Sai Muppala

added the logs

parent e9dfb3c3
......@@ -7,5 +7,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="slf4j-api-2.0.7" level="project" />
</component>
</module>
\ No newline at end of file
package Lambda;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
public class FunctionalInterfaceExample {
private static final Logger logger = LoggerFactory.getLogger(FunctionalInterfaceExample.class);
public static void main(String[] args) {
List<Person> people = new ArrayList<>();
people.add(new Person("harshitha",1));
......@@ -15,7 +23,7 @@ public class FunctionalInterfaceExample {
return person1.getAge() - person2.getAge();
});
for(Person person: people){
System.out.println(person.getName()+ " " +person.getAge());
logger.info(person.getName()+ " " +person.getAge());
}
}
......
package Lambda;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public interface FunctionalTest {
static final Logger logger = LoggerFactory.getLogger(FunctionalInterfaceExample.class);
void abstractTest(int x);
default void Message(){
System.out.println("hello");
logger.info("hello");
}
}
......
package Lambda;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PredicateExample {
private static final Logger logger = LoggerFactory.getLogger(FunctionalInterfaceExample.class);
public static void main(String[] args) {
Display i = () -> System.out.println("This is predicate example");
i.hello();
SumOfTwoIntegers s = (a, b) -> (a+b);
System.out.println(s.sum(5,6));
System.out.println(s.sum(7,7));
SumOfTwoIntegers s = (a, b) -> String.valueOf((a+b));
logger.info(s.sum(5,6));
logger.info(s.sum(7,7));
}
}
package Lambda;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
......@@ -8,6 +11,8 @@ import java.util.function.Predicate;
public class PredicateExample1 {
private static final Logger logger = LoggerFactory.getLogger(FunctionalInterfaceExample.class);
public static void main(String[] args) {
List<User> users = new ArrayList<User>();
users.add(new User("dev","Harshitha"));
......@@ -15,7 +20,7 @@ public class PredicateExample1 {
users.add(new User("QA","Anusha"));
List devs = process(users,(User u)->u.getRole().equals("dev"));
System.out.println(devs);
logger.info(devs.toString());
}
......
package Lambda;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.function.Predicate;
public class PredicateStringComparing {
private static final Logger logger = LoggerFactory.getLogger(FunctionalInterfaceExample.class);
public static void main(String[] args) {
String s1="hello";
String s2="hello";
Predicate<String> p = s->s.equals(s2);
if(p.test(s1)){
System.out.println("equal");
logger.info("equal");
}
else{
System.out.println("not equal");
logger.info("not equal");
}
}
......
......@@ -3,5 +3,5 @@ package Lambda;
public interface SumOfTwoIntegers
{
public abstract int sum(int a,int b);
public abstract String sum(int a, int b);
}
package Lambda;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.function.Consumer;
import java.util.function.Supplier;
public class SupplierExample {
public static void main(String[] args) {
private static final Logger logger = LoggerFactory.getLogger(FunctionalInterfaceExample.class);
public static void main(String[] args) {
//example of supplier
Supplier<String> supplier = () -> {
System.out.println("inside the supplier");
logger.info("inside the supplier");
return "hello";
};
String string = supplier.get();
System.out.println(string);
logger.info(string);
//example of consumer
Consumer<String> consumer = (String s) -> {
System.out.println("Inside the consumer");
System.out.println(s);
logger.info("Inside the consumer");
logger.info(s);
};
consumer.accept("hello");
Supplier<String> supplier1 = () -> {
System.out.println("Supplier");
logger.info("Supplier");
return "hello";
};
String s = supplier1.get();
System.out.println(s);
logger.info(s);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment