且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将 Java 中的数字填充到特定位数的最快方法

更新时间:2023-02-09 21:24:16

我将停止基于微基准进行优化,而转向代码方面看起来优雅的东西,例如 String.format("%0"+numDigits+"d", testNumber)

I would stop doing optimizations based on micro-benchmarks and go for something that looks elegant codewise, such as String.format("%0"+numDigits+"d", testNumber)