Common Mistakes in Java Programming

1. Not checking Null
No doubt. Null Pointers are the top mistake for most of JAVA programmers.
2. Confusing == with .equals()
I know you know about it but just to confirm == checks the reference. Two object pointing same object or not and .equals stands for comparing.
3. Accessing non-static variables from static method
4. Mistyping name of the method while overriding
You know the result better 😀
5. Confusing pass by value with pass by reference
Pass by value means copy of the data type is duplicated(copy). if a function modify it then the copy will be modified. But on Pass by reference so changes will be permanent.
6. Not trimming a string while converting to integer.
7. Binding a variable with value comes with http request parameter with same name
In Spring Framework: Suppose your bean contains a variable formId. If you send a request parameter like &formId=5678, The controller will automatically bind the value 5678 with formId

Leave a comment