首页题目详情

以下哪项是String.format()方法正确的调用方式?

题目配图
A.String.format("Hello %s");
B.String.format("Hello %s", "World");
C.String.format("Hello %s", 123);
D.String.format("Hello %s%b", true, "World");

优质解答

答案

B

解析

String.format()方法需要一个格式字符串和一个或多个参数。选项B正确传递了格式字符串和参数,其他选项均缺少必要参数或格式说明符不正确。

查看答案和解析

支付 ¥0.1 即可查看此题答案和详细解析

低至 ¥0.1 起

Java语言程序设计单选题中等AI生成