From c0962eca13a2f2c5dcb4a8b8e244bc619f10a6e2 Mon Sep 17 00:00:00 2001 From: Yassine Benabbas Date: Thu, 9 Nov 2023 11:57:44 +0100 Subject: [PATCH] Update some code --- .../samples/app/src/main/java/null_safety_java/App.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/material/samples/app/src/main/java/null_safety_java/App.java b/material/samples/app/src/main/java/null_safety_java/App.java index 2bf3b857..ad282c29 100644 --- a/material/samples/app/src/main/java/null_safety_java/App.java +++ b/material/samples/app/src/main/java/null_safety_java/App.java @@ -9,6 +9,9 @@ public class App { public static void main(String[] args) { + + int length = getLength(null); + @Nonnull String name; name = null; // warning @@ -19,9 +22,14 @@ public static void main(String[] args) { System.out.println(name2 == null ? 0 : name2.length()); } + public static int getLength(String name) { + return name.length(); + } + public static int getLength2(@Nullable String name) { if (name == null) return 0; return name.length(); } + }