Common Mistakes To Avoid

Understand the common mistakes and errors in order to avoid them.

❌ Common errors

Some common errors with methods that return values are:

  • Forgetting to write a return type before the method name
  • Forgetting to use the return keyword to return a value at the end of the method
  • Forgetting to store or print the return value after returning from a method
  • Adding a return type before the constructor name (like void)

🚨 An important alert

Look at the code below.

Get hands-on with 1400+ tech skills courses.