java format参数_Java开发网 - String.format()参数问题?

Posted by:xinhangyang

Posted on:2007-08-18 23:42

如下一个公有方法:

public String toString(){

return String.format( "%s: %s %s\n%s: %s\n%s: %.2f\n%s: %.2f\n",

"employeeName",firstName,lastName,

"socialSecurityNumber",socialSecurityNumber,

"grossSales",grossSales,

"commissionRate",commissionRate);

}

此方法功能 : 返回一个包含本对象5个私有变量的字符串

其中 firstName(String)

lastName(String)

socialSecurityNumber(String)

grossSales(double)

commissionRate(double) 为私有实例变量

编译后提示 The method format(String, Object[]) in the type String is not

applicable for the arguments (String, String, String, String,

String, String, String, double, String, double)

是不是参数配制的问题呢?可这是摘自deitel编的<>

在JDK1.6文档中对String.format 是这样介绍的

format(Locale l, String format, Object... args)

Returns a formatted string using the specified locale, format string, and arguments.

format(String format, Object... args)

Returns a formatted string using the specified format string and arguments.

会不会是调试环境搭建的问题?我用的是jdk1.6.0_02 和 eclipse3.0 .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值