This Study Resource Was
This Study Resource Was
import java.io.*;
import java.util.*;
class Employee
{
//Create the Constructor here
int id;
String name;
int age;
Employee(String name,int id,int age){
this.name=name;
this.id=id;
this.age=age;
}
}
class SortEmployees
{
void sortEmployees(ArrayList<Employee> empList)
{
m
er as
//Enter your Code here
co
Collections.sort(empList,(o1,o2) -> { return o1.name.compareTo(o2.name);
eH w
});
o.
for(Employee e:empList)
rs e
System.out.println(e.name+" "+e.id+" "+e.age);
ou urc
}
}
o
aC s
//////////////////////////////
v i y re
import java.io.*;
import java.util.function.*;
import java.util.function.Predicate;
import java.util.function.BiConsumer;
import java.util.function.IntPredicate;
ed d
import java.util.stream.IntStream;
ar stu
import java.util.stream.LongStream;
class PrimeComposite_Factorial
{
void primeOrComposite(int n)
sh is
{
Th
return true;//Prime
This study source was downloaded by 100000821315344 from CourseHero.com on 09-18-2021 16:13:05 GMT -05:00
https://www.coursehero.com/file/94160721/java8-innardstxt/
// if (isPrime == true && n1!=1)
// return true;
// else
// return false;
};
// System.out.println( pre.test(n));
void findFactorial(int n)
{
//Enter your Code here
Consumer<Integer> cc=(n1)->{
m
int c, f = 1;
er as
if (n1 < 0)
co
System.out.println("Number should be non-
eH w
negative.");
else
o.
{
rs e
for (c = 1; c <= n; c++)
ou urc
f = f*c;
System.out.println(f);
}
o
};
aC s
cc.accept(n);
v i y re
}
}
ed d
ar stu
///////////////////////
import java.io.*;
import java.lang.*;
import java.util.*;
sh is
import java.util.stream.IntStream;
import java.util.stream.Stream;
Th
import java.util.function.Consumer;
import java.util.function.Supplier;
class StoreElementsInCollection
{
static void storeElements(String input)
{
//Enter your Code here
String[] str = input.split(",");
List<String> l = new ArrayList<>();
Consumer<String> c=(s)->{
l.add(s);
};
for(int i =0;i<str.length;i++){
This study source was downloaded by 100000821315344 from CourseHero.com on 09-18-2021 16:13:05 GMT -05:00
https://www.coursehero.com/file/94160721/java8-innardstxt/
c.accept(str[i]);
}
// Supplier<Void> supp=()->{
// for(int i=0;i<l.size();i++){
// System.out.println(l.get(i));
// }
// };
// supp.get();
for(int i=0;i<l.size();i++){
// System.out.println(l.get(i)+l.size());
m
}
er as
co
public class StoreElementsInCollectionMain
eH w
o.
rs e
ou urc
o
aC s
v i y re
ed d
ar stu
sh is
Th
This study source was downloaded by 100000821315344 from CourseHero.com on 09-18-2021 16:13:05 GMT -05:00
https://www.coursehero.com/file/94160721/java8-innardstxt/
Powered by TCPDF (www.tcpdf.org)