String vs string code example

Example 1: What is the difference between String and string in C#?

string is an alias in C# for System.String.
So technically, there is no difference. It's like int vs. System.Int32

https://stackoverflow.com/questions/7074/what-is-the-difference-between-string-and-string-in-c

Example 2: string vs new string

String str = new String("");
String str2 = "";

They both immutable and they save in different 
memory location. String objects created without
the use of new keyword are stored in the
String Constant Pool part of the heap.
It doesn't create the same string object
if there is already string constant in the pool.

Tags:

Java Example