約4,350件1ページ目

日本語のみで絞り込む

条件を指定して検索しています。すべての条件を解除する

  • 最終更新日:1か月以内
  • 11時間前 -Java Optional ofNullable() Method: returns an Optional with the value, or an empty Optional if the value is null. Syntax, parameters and an example.

    2026/10/30 -The Optional.ofNullable() method creates an empty Optional when the supplied value is null. The following program demonstrates its string representation.

    4日前 -It can return null, or it can return a special empty value. Null is the default in the Java, and it is unchecked. Nothing in the type system warns you that ...

    2日前 -The most common Optional anti-pattern is wrapping a potentially null value in an Optional , only to immediately invoke .get() without checking if a value is ...

    5日前 -However, this time it also sets the optional field to an empty string if it's included but set to null. Let's use a test method to verify that the null value ...

    2026/10/10 -The orElse() method accepts null as the default, and orElseGet() returns whatever the supplier returns, including null. A null supplier is different, because ...

    3日前 -Java 8 adds the Optional<T> class, giving developers a way to explicitly signal that a value might be absent, rather than silently returning null. 2017+. Modern ...

    2026/10/22 -The null check above deliberately asks whether a lookup returned an object. After that check, placing the Integer into the primitive result array unboxes it ...

    9時間前 -Step 1: use Optional when absence is legitimate. Java 8 introduced Optional , which explicitly represents a value that may or may not exist. · Step 2: use ...

    2026/11/1 -Effective Java covers both choices, in Items 54 and 55 of the third edition, as returning empty collections instead of null and returning optionals judiciously.