Import java. util. *; import java. io. *; import java. SQL. *; import java. text. *; import java. util. regex. *; public class Test {public static void main (String [] args) throws Exception {long starttime = System. currentTimeMillis (); String s = ""; boolean flag = true; // in a changed environment
// In a constant environment, use the following method for the fastest speed (int I = 0; I <999999; I ++) {if (flag) {s = I + "" ;}else {s = 9 + "" ;}} System. out. println (System. currentTimeMillis ()-starttime );
// In a changed environment, use the following method for the fastest speed: starttime = System. currentTimeMillis (); for (int I = 0; I <999999; I ++) {if (flag) {s = Integer. toString (I);} else {s = Integer. toString (9) ;}} System. out. println (System. currentTimeMillis ()-starttime); // This method seems redundant starttime = System. currentTimeMillis (); for (int I = 0; I <999999; I ++) {if (flag) {s = String. valueOf (I);} else {s = String. valueOf (9) ;}} System. out. println (System. currentTimeMillis ()-starttime );
// In whatever circumstances, the speed and efficiency are the worst starttime = System. currentTimeMillis (); for (int I = 0; I <999999; I ++) {if (flag) {s = new Integer (I ). toString ();} else {s = new Integer (9 ). toString () ;}} System. out. println (System. currentTimeMillis ()-starttime );}};
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service