C 中的printf()语句返回它打印的字符数。
我想计算System.out.println()语句打印的字符数。有什么方法可以计算吗?
查看(的类)的JavadocPrintStreamSystem.out。所有常规print方法都返回void.
如果您真的想知道打印的字符数,则需要格式化字符串(String#format,相当于sprintf),处理 EOL,然后查看长度。
Put what you are printing into a string first, then get the length of it.