Question: Do this Java Task Urgent in Netbeans 8.2 Part 1: import java.util.*; import java.util.stream.Collectors; public class Filter { public static List apply( List lst, Double

Do this Java Task Urgent in Netbeans 8.2

Do this Java Task Urgent in Netbeans 8.2 Part 1: import java.util.*;

Part 1:

import java.util.*;

import java.util.stream.Collectors;

public class Filter {

public static List apply(

List lst, Double target){

return lst.stream()

.mapToDouble( Number::doubleValue )

.filter( elem -> elem > target )

.boxed()

.collect( Collectors.toCollection(

ArrayList::new ) );

}

public static void main(String[] args) {

// Integer[] nums = new Integer[] {1,2,3,4,5,6,7,8,9};

Double[] nums = new Double[] {2.1,3.2,4.3,5.4,6.5,7.6,8.7};

System.out.println(

Filter.apply( Arrays.asList(nums), 5.0 )

);

}

}

Figure 1: Filter the numeric elements based on target value

Part 2:

import java.util.*;

import java.util.stream.*;

public class Demo {

public static void main(String[] args) {

String[][] lst = {

{ "a", "b" }, { "c", "d", "e", "f" }

};

Stream stream = Arrays.stream(lst);

System.out.println( stream

.flatMap( arr -> Arrays.stream(arr) )

.collect( Collectors.toCollection( LinkedList::new ) )

);

}

}

Figure 2: Joining the elements from the array objects as a collection of objects

Analyse the following Java code in Figure 1 and 2. Rewrite the given program code using logic programming paradigm. Prolog. Your solution should include recursive concept and demonstrate the query sample. Part 1: import java.util. *; import java.util.stream Collectors: public class Filter { public static List apply List Ist, Double target){ return Ist.stream mapToDouble( Number doubleValue) filter( elem -> elem > target) .boxedo collect( Collectors to Collection ArrayList:new)); } public static void main(String[] args) { // Integer[] nums = new Integer[] {1,2,3,4,5,6,7,8,9}; Double[] nums = new Double[] {2.1, 3.2.4.3,5.4.6.5 7.6,8.7}; System.out.println( Filter.apply( Arrays.asList(nums), 5.0 ) ); } } Figure 1: Filter the numeric elements based on target value Part 2: import java.util.*; import java.util.stream.*; public class Demo public static void main(String[] args) { String[][] Ist = { {"a", "b"}, {"c", "d", "e", "f"} }; Stream stream = Arrays.stream(Ist); System.out.println( stream flatMap(arr-> Arrays.stream(ar)) collect( Collectors to Collection LinkedList-new)) ); } } Figure 2: Joining the elements from the array objects as a collection of objects Analyse the following Java code in Figure 1 and 2. Rewrite the given program code using logic programming paradigm. Prolog. Your solution should include recursive concept and demonstrate the query sample. Part 1: import java.util. *; import java.util.stream Collectors: public class Filter { public static List apply List Ist, Double target){ return Ist.stream mapToDouble( Number doubleValue) filter( elem -> elem > target) .boxedo collect( Collectors to Collection ArrayList:new)); } public static void main(String[] args) { // Integer[] nums = new Integer[] {1,2,3,4,5,6,7,8,9}; Double[] nums = new Double[] {2.1, 3.2.4.3,5.4.6.5 7.6,8.7}; System.out.println( Filter.apply( Arrays.asList(nums), 5.0 ) ); } } Figure 1: Filter the numeric elements based on target value Part 2: import java.util.*; import java.util.stream.*; public class Demo public static void main(String[] args) { String[][] Ist = { {"a", "b"}, {"c", "d", "e", "f"} }; Stream stream = Arrays.stream(Ist); System.out.println( stream flatMap(arr-> Arrays.stream(ar)) collect( Collectors to Collection LinkedList-new)) ); } } Figure 2: Joining the elements from the array objects as a collection of objects

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!