Use Function and BiFunction Interfaces in Lambda Expression in Java

raja
Updated on 13-Jul-2020 06:37:00

2K+ Views

The Function interface is a pre-defined functional interface that can be used as an assignment target for a lambda expression or method reference. It takes a single parameter and returns result by calling the apply() method. While the BiFunction interface is also a pre-defined functional interface that takes two parameters and returns a result. It is similar to the Function interface except it takes two parameters.Syntax@FunctionalInterface public interface Function @FunctionalInterface public interface BiFunctionExampleimport java.util.function.BiFunction; import java.util.function.Function; public class SampleFunctionBiFunctionTest {    public static void main(String[] args) {       Function printNumber = a -> a*10;       System.out.println("The number is: "+ printNumber.apply(10));   ... Read More

Use Consumer and BiConsumer Interfaces in Lambda Expression in Java

raja
Updated on 13-Jul-2020 06:30:59

4K+ Views

A Consumer interface is a predefined functional interface that can be used when creating lambda expressions or method references. This interface represents an operation that accepts a single input parameter and doesn't return anything. It contains only one method named accept(). The BiConsumer interface is similar to a Consumer interface and accepts two input parameters and doesn’t return anything.Syntax@FunctionalInterface public interface Consumer @FunctionalInterface public interface BiConsumerExampleimport java.util.*; import java.util.function.*; public class ConsumerBiConsumerTest {    public static void main(String[] args) {       Consumer c = (x) -> System.out.println(x.toLowerCase());  // lambda expression       c.accept("Raja");         Consumer con = (x) -> {  // ... Read More

Spanning Tree Protocol

Moumita
Updated on 13-Jul-2020 05:50:38

6K+ Views

Spanning Tree Protocol (STP) is a communication protocol operating at data link layer the OSI model to prevent bridge loops and the resulting broadcast storms. It creates a loop − free topology for Ethernet networks.Working PrincipleA bridge loop is created when there are more than one paths between two nodes in a given network. When a message is sent, particularly when a broadcast is done, the bridges repeatedly rebroadcast the same message flooding the network. Since a data link layer frame does not have a time-to-live field in the header, the broadcast frame may loop forever, thus swamping the channels.Spanning ... Read More

What is Wormhole Switching

Moumita
Updated on 13-Jul-2020 05:48:37

1K+ Views

In data communications, wormhole switching a flow control technique where large data frames or packets are partitioned and then transmitted. When a switching device (a bridge or a switch) receives a data packet, it partitions the packet into small parts called flow control units or flits. The flits are transmitted one by one instead of the whole packet. Also called wormhole flow control, wormhole switching is subtype of flit-buffer flow control methods and is based upon fixed links.Working PrincipleIn this technique, each packet or frame is broken into smaller pieces of data called flits. The header flits contain the destination ... Read More

What is Cut-Through Switching?

Moumita
Updated on 13-Jul-2020 05:48:03

819 Views

In data communications, cut-through switching is a method of switching data frame or data packets, where the switching device (bridge or switch) forwards the frames or packets as soon as the destination address is available without waiting for the rest of the data to arrive.Working PrincipleCut-through switching is used in packet switching systems. In packet-switching, the message is divided into a number of units called packets that are individually routed from the source to the destination. There is no need to establish a dedicated circuit for communication, since it is a connectionless network switching technique.In cut − through switching, when ... Read More

Uses of Bridges in Computer Network

Moumita
Updated on 13-Jul-2020 05:47:03

10K+ Views

A bridge is a network device that connects multiple LANs (local area networks) together to form a larger LAN. The process of aggregating networks is called network bridging. A bridge connects the different components so that they appear as parts of a single network. Bridges operate at the data link layer of the OSI model and hence also referred as Layer 2 switches.The following diagram shows a bridges connecting two LANs −Uses of BridgeBridges connects two or more different LANs that has a similar protocol and provides communication between the devices (nodes) in them.By joining multiple LANs, bridges help in ... Read More

What is Virtual LAN

Moumita
Updated on 13-Jul-2020 05:44:51

16K+ Views

Virtual Local Area Networks or Virtual LANs (VLANs) are a logical group of computers that appear to be on the same LAN irrespective of the configuration of the underlying physical network. Network administrators partition the networks to match the functional requirements of the VLANs so that each VLAN comprise of a subset of ports on a single or multiple switches or bridges. This allows computers and devices in a VLAN to communicate in the simulated environment as if it is a separate LAN.Features of VLANsA VLAN forms sub-network grouping together devices on separate physical LANs.VLAN's help the network manager to ... Read More

What is Data Link Layer Switching?

Moumita
Updated on 13-Jul-2020 05:43:50

17K+ Views

Network switching is the process of forwarding data frames or packets from one port to another leading to data transmission from source to destination. Data link layer is the second layer of the Open System Interconnections (OSI) model whose function is to divide the stream of bits from physical layer into data frames and transmit the frames according to switching requirements. Switching in data link layer is done by network devices called bridges.BridgesA data link layer bridge connects multiple LANs (local area networks) together to form a larger LAN. This process of aggregating networks is called network bridging. A bridge ... Read More

Implement Instance Method Reference Using a Class Name in Java

raja
Updated on 13-Jul-2020 05:40:25

831 Views

Method reference is a simplified form of the lambda expression. It can specify a class name or instance name followed by the method name. The "::" symbol can separate a method name from the name of an object or class.An instance method reference refers to an instance method of any class. In the below example, we can implement an instance methods reference using the class name.Syntax::Exampleimport java.util.*;; import java.util.function.*; public class ClassNameRefInstanceMethodTest {    public static void main(String args[]) {       List empList = Arrays.asList(          new Employee("Raja", 15000),          new Employee("Adithya", 12000),          new Employee("Jai", 9000),   ... Read More

Generate a Strong Password Using PowerShell

Chirag Nagrekar
Updated on 13-Jul-2020 05:39:25

562 Views

To generate a strong password with the PowerShell, we can use 8 or more characters password. In the below example, we are going to use the 8 character password, you can change the number of characters as per your convenience.This script you can bind into windows forms and provide it to the IT helpdesk to set the password for new users.In this example, we will use the Random integers between 33 and 126 and convert it to the Character, considering them they are the ASCII values for characters.You can find more about ASCII values in the table provided in the ... Read More

Advertisements