diff --git a/guide/english/java/strings/index.md b/guide/english/java/strings/index.md index 8289013d99..ddebc30d03 100644 --- a/guide/english/java/strings/index.md +++ b/guide/english/java/strings/index.md @@ -18,7 +18,7 @@ true You can create a String Object in the following ways: 1. `String str = "I am a String"; //as a String literal` -1. `String str = "I am a " + "String"; //as a constant expression` +1. `String str = "I" + " am" + " a" + " String"; //as a constant expression (note that spaces are in the quotes)` 1. `String str = new String("I am a String"); //as a String Object using the constructor` You might be thinking: What's the difference between the three? @@ -82,9 +82,11 @@ s3: example ``` #### Comparing Strings + If you want to compare the value of two String variables, you can't use `==`. This is due to the fact that this will compare the references of the variables and not the values that are linked to them. To compare the stored values of the Strings you use the `.equals()` method. + ```java boolean equals(Object obj) ```