sample_code

package org.example;

import java.util.ArrayList;
import java.util.List;

public class LambdaTest {
     static class Employee {
        String name;
        String address;
        long salary;

         public Employee(String name, String address, long salary) {
             this.name = name;
             this.address = address;
             this.salary = salary;
         }

         public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public long getSalary() {
            return salary;
        }

        public void setSalary(long salary) {
            this.salary = salary;
        }

         @Override
         public String toString() {
             return "Employee{" +
                     "name='" + name + '\'' +
                     ", address='" + address + '\'' +
                     ", salary=" + salary +
                     '}';
         }
     }

    public static void main(String[] args) {
        List<Employee> empList = new ArrayList<>();
        empList.add(new Employee("Kishore", "hyd", 1235));
        empList.add(new Employee("Renu", "nz", 2345));
        empList.add(new Employee("Cherry", "pan", 5678));
        empList.add(new Employee("Gaya3", "BZA", 56798));
        List<Employee> finalList = empList.stream().filter(emp -> emp.getSalary() < 3000).peek(e -> e.setSalary(15000)).toList();
        System.out.println(finalList);
    }


}

 

 

+++++++++++++++++++++++++++

 

 

package org.example;

public class RunnableTest {

    public static void main(String[] args) {
        new Thread(new SampleThread()).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("i am thread");
            }
        }).start();
        new Thread(() -> System.out.println("i am thread...?")).start();
    }


}

 

+++++++++++++++++++++++

 

package org.example;

public class SampleThread implements Runnable {
    @Override
    public void run() {
        System.out.println("i Am full class thread...!");
    }
}

 

 

+++++++++++++++++++++++++++++

 

package org.example;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public class PredicateTest {
    public static void main(String[] args) {
        List<String> names = Arrays.asList("kishore", "Gayathre", "cherry", "renu");
        Predicate<String>  pre = e -> e.endsWith("e");
        names.forEach(e -> {
            if(pre.test(e))
                System.out.println(e);
        });
    }
}