Common Mistakes To Avoid

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

We'll cover the following

❌ Common pitfalls

The following common mistakes should be avoided:

  • Declaring a string with string identifier instead of String

  • Enclosing a string in '' (single quotes)

  • Ignoring the difference between the String literal and the String object

  • Trying to modify the original string

  • Treating the == operator and the equals() method equally when comparing two strings

  • Using / instead of \ for the escape sequence

  • Calling a method on a String type object incorrectly (not using the . operator)

  • Forgetting to enclose the string in double quotes properly (for example, "Java instead of "Java")


Get hands-on with 1400+ tech skills courses.