if you just assign a string literal ["q" is called literal] compiler will check whether are there any String object having the same string pointed by them the i'll give the same reference to the object 's'. That means if there is a line of code like
before the line
both the variables 'r' and 's' will point to the same location.
On the other hand if you use the new keyword it'll allocate memory for the string object and give the reference to the String object.
- Rakesh