From d616006a5f37c4eea9f51823d551a5e659e847bb Mon Sep 17 00:00:00 2001 From: Maia Everett Date: Sat, 30 Aug 2025 20:52:06 +0300 Subject: [PATCH] Invoke a Method: Clarify how the first argument works for static methods --- src/reflection/invoke_a_method.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/reflection/invoke_a_method.md b/src/reflection/invoke_a_method.md index f50c3b70..601dbd76 100644 --- a/src/reflection/invoke_a_method.md +++ b/src/reflection/invoke_a_method.md @@ -37,7 +37,7 @@ class Tea { ``` For static methods you do not need an instance of the class to invoke them. -Instead you need to pass the class itself as the first argument to `.invoke`. +Instead, the first argument is ignored. You can pass `null`. ```java import java.lang.reflect.InvocationTargetException; @@ -55,8 +55,8 @@ class Main { throw new RuntimeException(e); } - biteMethod.invoke(Apple.class, 5); - biteMethod.invoke(Apple.class, 1); + biteMethod.invoke(null, 5); + biteMethod.invoke(null, 1); } }