Sprintf等同于Java [英] Sprintf equivalent in Java
本文介绍了Sprintf等同于Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
//将格式化的字符串存储在'result'中
字符串结果= String.format(%4d,i * j);
//将结果写入标准输出
System.out.println(result);
Printf got added to Java with the 1.5 release but I can't seem to find how to send the output to a string rather than a file (which is what sprintf does in C). Does anyone know how to do this?
解决方案
// Store the formatted string in 'result'
String result = String.format("%4d", i * j);
// Write the result to standard output
System.out.println( result );
这篇关于Sprintf等同于Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文