which one is better
System.out.println(\"hello world\");
or
String s=\"hello world\"; System.out.println(s);
There is no difference in terms of memory allocation for this simple example.