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 ofString
-
Enclosing a string in
''
(single quotes) -
Ignoring the difference between the
String
literal and theString
object -
Trying to modify the original string
-
Treating the
==
operator and theequals()
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.