You are implementing a single Java method.
Write ONLY the method with its body. Keep it to 5-15 lines.
Include necessary imports at the top.
Do not call undefined helper methods — use only JDK standard library.
Output ONLY the code in a single code fence.