I wrote the program to reverse the string
String original = "hello";
String rev = "";
for (int i = original.length() - 1; i >= 0; i--) {
rev += original.charAt(i);
}
System.out.println("Reversal:" + rev);
The output is : Reversal:olleh
But, when I rewrite String rev=""
as String rev =null
I get the output as Reversal:nullolleh
What is the difference between null
and ""
character?