CORE API / CATATAN</>↗Core API21 Mar 2025
In Java, DatagramSocket and DatagramPacket are part of the java.net package and are commonly used for implementing communication through the User Datagram Protocol (UDP). Here’s how we can send and receive data using these classes: Steps for Sending and Receiving Data Using DatagramSocket Create a DatagramSocket: For sending, bind the socket to any available port […]
CORE API / CATATAN</>↗Core API20 Mar 2025
Using Socket and ServerSocket in Java is quite straightforward for creating TCP-based communications. Below is an explanation describing how to use these classes, along with sample code to implement a basic client-server communication. Key Classes ServerSocket Used by the server to listen for incoming client connections on a specific port. Socket Used by both the […]
CORE API / CATATAN</>↗Core API20 Mar 2025
The UnaryOperator functional interface in Java is a specialized form of the Function functional interface. It is used when both the input and output of a function are of the same type. This interface plays a role when we want to perform an operation on a single operand and return a result of the same […]
CORE API / CATATAN</>↗Core API19 Mar 2025
The ToLongBiFunction is a functional interface introduced in Java. It is part of the java.util.function package, and it represents a function that accepts two arguments (of generic types) and produces a long result. The functional method in this interface is: long applyAsLong(T t, U u); Here’s how we can effectively use the ToLongBiFunction: Steps to […]
CORE API / CATATAN</>↗Core API19 Mar 2025
The ToIntFunction functional interface in Java is part of the java.util.function package and represents a function that accepts one argument and produces a int-valued result. It is a functional interface with a single abstract method int applyAsInt(T value), making it a good candidate for usage in lambda expressions or method references. Here’s how to use […]
CORE API / CATATAN</>↗Core API19 Mar 2025
The ToIntBiFunction is a functional interface in Java that comes from the java.util.function package. It represents a function that accepts two arguments and produces an int as a result. This interface is useful when we need to create a lambda expression or method reference that takes in two arguments of generic types and returns an […]