INT conversion to String method selection

xiaoxiao2021-03-06  61

We often encounter problems that need to be converted to String, and give four conversion methods below. In that way, the method is best. 1. "" " i2.new integer (i) .tostring (); 3. String.Valueof (i); 4.INTEGER.TOSTRING (i); like the first method is more common, the second is relatively rare. Readability: The first one is the worst, the third and 4 are very good , The second time. Performance comparison: The first is the worst, the test cycle is performed at the time of the conversion time 3: 2: 1: 1. It can be seen that the first and second China method are not desirable, the fourth The best method, the third type is almost directly call 4. So should choose 4, I am very wondering that many people like to use 1, not only the ability to readability, but also the performance, mainly the number of characters to write, mainly the number of characters to write. .

转载请注明原文地址:https://www.9cbs.com/read-119547.html

New Post(0)