Java Stream API — Even Numbers (Full Screen) Java Stream API — Get Even Numbers Example 1 — Filter even numbers from a list Creates a list, uses Stream to filter evens, and prints them. Copy import java.util.*; import java.util.stream.*; public class EvenNumbersStream { public static void main(String[] args) { // Create a list of numbers List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // Use Stream API to filter even numbers List<Integer> evenNumbers = numbers.stream() .filter(n -> n % 2 == 0) .collect(Collectors.toList()); // Print the even numbers System.out.println( "Even numbers: " + evenNumbers); } } Example 2 — Use IntStream.rangeClosed ...
In this C program we will concatenate the source string at the end of the target string using strcat() fuction. The String will be given by the User. strcat() function concatenates the source string which is source_str in this program, at the target string which is target_str in this program. strcat() takes two arguements. Like : strcat(target_str,source_str); Learn about different string functions and their use: Different String Functions input: The String. output: The input string and the concatenated string will be printed on the screen. CODE----> #include<stdio.h> #include<string.h> int main () { char source_str [ 100 ], target_str [ 100 ]= "Hello " ; printf ( "Please, Enter the string: " ); gets ( source_str ); strcat ( target_str , source_str ); printf ( "\nSource String is: " ); puts ( source_str ); printf ( "\nTarget String is: " ); puts ( target_str ); return 0 ; } ...