Update index.md (#25592)

* Update index.md

* Update index.md
This commit is contained in:
mian3se
2018-12-20 17:43:07 -08:00
committed by Manish Giri
parent 643fa813c3
commit 067d832ea6

View File

@ -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)
```