Skip to main content

Posts

Showing posts from January, 2018

Get Even Numbers Using Java Stream API

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 ...

OR Gate

OR Gate Introduction :- The OR Gate performs logical addition, commonly known as OR function. The OR Gate has two or more inputs and only one output. The operation of OR Gate is such that a HIGH (1) on the output is produced when any of the input is HIGH (1). The output is LOW (0) only when all the inputs are LOW (0). Logic Expression :- If A and B are the input variables of an OR Gate and Y is it's output, then, Y = A + B Truth-Table :- Truth-Table of OR Gate Logic Symbol of 2-input OR Gate :- Logical symbol of 2-input OR Gate OR Gate's IC-base diagram :- OR-Gate's IC-base diagram Apparatus :- Bread-board, LED-light, Battery(Power-Supply), IC-7432, Multimeter and Resistance. Procedure :-      1. Verify whether all the wires and components are in good condition.      2. Set-...