Why Optional Should NOT Be Used as a Method Parameter in Java

Many Java developers know about Optional, but it's often used incorrectly. In this video, I explain why using Optional as a method parameter is generally considered a bad practice and why it works much better as a return type. Topics covered: • Why Optional was introduced • Problems with Optional parameters • Additional burden on client code • Null-related pitfalls • Why Optional parameters can still lead to NullPointerExceptions • Recommended alternatives • Using Optional as a return type • Java Optional best practices Code examples included throughout the video. If you're preparing for Java interviews, improving code quality, or learning modern Java best practices, this video is for you. #java #javaprogramming #backend #springboot #cleancode 00:00 Introduction 00:43 Code Walkthrough 01:52 Client Code 02:58 Problems with the Approach 03:41 Demo: Passing Null to Optional Parameter 04:53 Better Alternatives and Fix 06:02 Optional as Return Type 06:23 Not Using Optional as return type - Issues 09:03 Closing Comments