1. Question:
Long.valueof ("" + Requestcontext.globaldata ("Count"));
Why do you need to add "". 2. Answer:
Because, "" is a string, a string plus an object is automatically converted to a string type, and when we debug, if we want to print the object, we should write it carefully:
Object A=new object ();
.../omitted the value given to a to set the individual member variables;
console.log ("Object:" +a)
Because if a is an object, you add a string object to it before you turn it into a string type in debug, and you must look at your needs at this time.
The code in the question can also be written like this:
Long.valueof ((String) requestcontext.globaldata ("Count")
But this is not good, because the type of the strong switch is likely to fail, which is why we have not used (Long) to strongly turn the reason, and then further modified to
Long.valueof (String.valueof (Requestcontext.globaldata ("Count"));
But it is too complicated to write, and the wording of the question is better. Here, if long has a method similar to "", we can convert it in the same way, but I don't know at the moment (not ironic, really not yet), and then the question is, what's the difference between "" and "null"? the difference between 3.null and "";
Why is the difference between "" and null, now the title is changed to null and "" The difference, the reason behind it, sell a word;
The difference is as follows:
①null is empty, nothing, I do not have a house; "Yes, I have a house, but the house is empty; it's a qualitative distinction, The difference is very large;
②string s1=null unassigned address, String s2= "" Assigned address,
③null with equal sign comparison, "" with equals, and first judge is not NULL, and then judge is not "", that is, first judge there is no, Again judge is not empty; here, I feel, null can not be directly translated into "empty", but should be translated into "none", because "" "Chinese name is" empty string ", so that the name will be ambiguous, so that beginners misunderstood, and even a lot of veteran overturned; if (null==s1| | (""). Equals. (S2)), otherwise it will report null pointer exception error; here null to write = = The front, s1 to write = = behind, this is a specification, but also to avoid error tips;