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 ...
String Functions
Please, include "String" header file, before using these functions.
#include<string.h>
strlen()
Finds length of a string
strlwr()
Converts a string to lowercase
strupr()
Converts a string to uppercase
strcat()
Appends one string at the end of another
strncat()
Appends first n characters of a string at the end of another
strcpy()
Copies a string into another
strncpy()
Copies first n characters of one string into another
strcmp()
Compares two strings
strncmp()
Compares first n characters of two strings
strcmpi()
Compares two strings by ignoring the case
stricmp()
Compares two strings without regard to case (identical to strcmpi)
strnicmp()
Compares first n characters of two strings without regard to case
strdup()
Duplicates a string
strchr()
Finds the first occurrance of a given character in a string
strrchr()
Finds the last occurrance of a given character in a string
strstr()
Finds first occurrance of a given string in another string
strset()
Sets all characters of string to a given character
strnset()
Sets first n characters of a string to a given character
strrev()
Reverses string
**All Data Collected From "Let Us C" by Yashavant Kanetkar**
Download the exact above information as a document file.
Comments
Post a Comment