Import java.util. *; import java.io. *; 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; // changing environment
/ / In a constant environment, the following method speed is used to quickly (int i = 0; I <99999; i ) {if (flag) {s = i ";} else {s = 9 " " }} System.out.println (System.currentTimeMillis () - startTime);
// In a changing environment, use the following method speed upstaltTime = system.currenttimeMillis (); for (int i = 0; i <999999; i ) {if (flag) {s = integer.tostring (i); } else {s = integer.tostring (9);}} system.crenttimemilln (system.currenttimemillis () - starttime); // This method seems to be 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 any case, speed and efficiency are the worst of StartTime = System.currentTimeMillis (); for (int i = 0; i <99999; i ) {if (flag) {s = new integer (i) .tostring ();} else {s = new integer (9) .tostring ();}} system.out.println (system.currenttimemillis () () - startTime);}