Ruang penulis
SEBUAH JURNAL TENTANG TEKNOLOGI

Belajar hal baru.
Tulis. Bagikan.

Ruang untuk merangkai pengetahuan, satu baris kode setiap hari.
Temukan tutorial, ide, dan catatan dari perjalanan belajar.

1914 catatan & terus bertumbuh
PILIHAN EDITOR
Java

Memahami Java Stream: olah koleksi dengan lebih ringkas

Pelajari alur filter, map, dan collect untuk mengolah data Java dengan kode yang mudah dibaca.

D Tim Diary Coding · 1 menit baca
UNTUK RASA INGIN TAHUMU

Catatan terbaru.

UTIL PACKAGE / CATATAN</>
Util Package27 Apr 2025

How do I filter Optional values based on a condition?

In Java, you can use the Optional API to filter values based on a condition using the filter method. The filter method takes a predicate as an argument and applies it to the value contained in the Optional. If the predicate evaluates to true, the Optional is returned unchanged. If the predicate evaluates to false, […]

Wayan · 2 menit baca
UTIL PACKAGE / CATATAN</>
Util Package27 Apr 2025

How do I use Optional to refactor nested null checks?

Using Optional in Java is a great way to refactor nested null checks into more readable and maintainable code. Below, I’ll explain how you can use Optional to replace deeply nested null checks step by step with examples. Example of Nested Null Checks Consider this code with deeply nested null checks: String streetName = null; […]

Wayan · 3 menit baca
JSCH / CATATAN</>
JSch26 Apr 2025

How do I handle session and channel cleanup in JSch?

When using JSch (Java Secure Channel) to establish SSH connections in your Java application, it’s essential to properly manage resources like Session and Channel objects to prevent resource leaks. Cleanup involves explicitly closing all channels and disconnecting the session once the work is complete. Here is how you can handle session and channel cleanup in […]

Wayan · 4 menit baca
UTIL PACKAGE / CATATAN</>
Util Package26 Apr 2025

How do I conditionally execute code with Optional’s ifPresent and ifPresentOrElse?

In Java, the Optional class provides methods for handling values that may or may not be present. The methods ifPresent and ifPresentOrElse are particularly useful for executing code conditionally based on whether a value is present in the Optional. 1. Using ifPresent The ifPresent method executes a Consumer when the value is present (i.e., it’s […]

Wayan · 3 menit baca
UTIL PACKAGE / CATATAN</>
Util Package26 Apr 2025

How do I throw exceptions if Optional is empty using orElseThrow?

In Java, you can throw exceptions when an Optional is empty using the orElseThrow method. This method accepts a Supplier that provides the exception to be thrown if the Optional is empty. Here’s the syntax and an example: package org.kodejava.util; import java.util.Optional; public class Main { public static void main(String[] args) { Optional<String> optionalValue = […]

Wayan · 2 menit baca
JSCH / CATATAN</>
JSch25 Apr 2025

How do I run a simple command over SSH with JSch?

To execute a simple command over SSH using JSch (Java Secure Channel), you can use the ChannelExec channel provided by the JSch library. Here’s how you can achieve that: Maven Dependency: If you’re using Maven, include the JSch library in your pom.xml file: <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.55</version> <!– Use the latest version –> </dependency> Code […]

Wayan · 3 menit baca

Pengetahuan tumbuh ketika dibagikan.

Simpan rasa ingin tahu. Selalu ada hal baru untuk dipelajari.

Jelajahi catatan ↗
Putu Adi Guna Permana
TENTANG PENULIS

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Penulis dan pendiri Diary Coding — berbagi catatan, tutorial, dan pengalaman seputar pemrograman untuk siapa pun yang ingin terus belajar.