UTIL PACKAGE / CATATAN</>↗Util Package29 Apr 2025
Using Optional as a method parameter in Java is discouraged because it goes against the intended purpose of Optional and can lead to inefficiencies, poor readability, and unintended complications in the code. Here’s why it matters and how to avoid using Optional as a method parameter. Why Should You Avoid Optional as a Method Parameter? […]
JSCH / CATATAN</>↗JSch28 Apr 2025
When using the JSch library for SSH connections in Java, it is essential to handle connection errors gracefully to ensure your application remains robust and can recover effectively from issues like authentication failures, host connectivity issues, or unexpected disconnections. Here’s a structured way to handle connection errors gracefully using JSch: Steps to Handle Errors Gracefully […]
UTIL PACKAGE / CATATAN</>↗Util Package28 Apr 2025
Integrating Optional with Java Streams can simplify many common scenarios when working with potentially absent values. Here are different techniques depending on your specific use case: 1. Use Optional in Stream Pipelines When you have an Optional and you want to integrate it into a Stream pipeline, you can use stream() from Java 9 onward. […]
BASIC / CATATAN</>↗Basic28 Apr 2025
Type inference was introduced in Java 10 with the new var keyword, enabling developers to declare local variables without explicitly specifying their type. This feature can help create cleaner, more concise code by reducing boilerplate, though it should be used judiciously to maintain code readability. Here’s a guide on how to use type inference effectively […]
UTIL PACKAGE / CATATAN</>↗Util Package28 Apr 2025
Combining multiple Optional objects in Java in a functional style is a common need, especially when working with potentially nullable values without resorting to null checks. Here are examples of some approaches you can use based on the scenario: 1. Combining If All Optionals Are Present If you want to combine values only when all […]
JSCH / CATATAN</>↗JSch27 Apr 2025
To load a private key for SSH authentication using JSch (Java Secure Channel), you can use the addIdentity method available in the JSch class. This method allows you to specify the private key (and optionally, the public key or passphrase) used for key-based authentication. Here is an example of how to accomplish this: Example Code […]