重用String.format中的参数? [英] Reuse a parameter in String.format?

查看:183
本文介绍了重用String.format中的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

String hello = "Hello";

String.format("%s %s %s %s %s %s", hello, hello, hello, hello, hello, hello);

hello hello hello hello hello hello 

在对format方法的调用中是否需要多次重复hello变量,还是有一个速记版本可以让您一次指定参数以应用于所有%s标记?

Does the hello variable need to be repeated multiple times in the call to the format method or is there a shorthand version that lets you specify the argument once to be applied to all of the %s tokens?

推荐答案

来自

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆