From 067d832ea6d63ebfdd711e07fb03bdd545dab21d Mon Sep 17 00:00:00 2001 From: mian3se <44347607+mian3se@users.noreply.github.com> Date: Thu, 20 Dec 2018 17:43:07 -0800 Subject: [PATCH] Update index.md (#25592) * Update index.md * Update index.md --- guide/english/java/strings/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) ```