The method format(String, Object[]) in the type String is not applicable for the arguments
今天,我弟遇到一个有意思的错误~
程序:
package com.mq.ceshi1;
public class StringFormat {
public static void main(String[] args) {
int num = 10;
int num2 = 5;
System.out.println(String.format("%d / %d = %d", num,num2,num / num2));
}
}
报了The method format(String, Object[]) in the type String is not applicable for the arguments (String, int,int,int)错误。
首先分析一下,jdk文档:

可见,这个是在1.5版本后添加的。
后来,根据网上的修改,按以下运行也是正常的。
package com.mq.ceshi1;
public class StringFormat {
public static void main(String[] args) {
// int num = 10;
// int num2 = 5;
Integer [] nums = {10,5,2};
// System.out.println(String.format("%d / %d = %d", num,num2,num / num2));
System.out.println(String.format("%d / %d = %d", nums));
}
}
查看了出问题机器使用的是:jdk版本也是1.7.8 myecliplse8.6
由于版本大于1.5,但是我还是怀疑是版本引起的。于是,在有问题的机器上,由使用了1.5版本之后才有的自动拆装箱机制。
Integer num = 5; //发现报错
进一步验证了我关于版本可能带来的错误。
于是,将myecliplse版本升级到2014版,发现问题消失。
总结:怀疑是myeclipse8.6版本与jdk1.7.8存在不兼容的问题。(暂无直接证据,如果哪位有方法验证的话,请不吝赐教!!)
The method format(String, Object[]) in the type String is not applicable for the arguments的更多相关文章
- The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (GameV
在当前短信内容的activity中写 Bundle bun = new Bundle(); bun.putString("message", ...
- 错误:The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, MyFragment)
Fragment newfragment =new MyFragment();fragmentTransaction.replace(R.layout.activity_main,newfragmen ...
- The method load(Class, Serializable) in the type HibernateTemplate is not applicable for the arguments (Class, int)
引入别人的项目发现利用HibernateTemplate的load的方法报错了.错误提示为: The method load(Class, Serializable) in the type Hibe ...
- The method setOnClickListener(View.OnClickListener) in the type View is not applicable
开始学习 android 了,学习的是高明鑫老师的android视频教程(android视频教学). 学到第八讲时, 在写动态设置时报错: The method setOnClickListener( ...
- The method setItems(String) in the type ForTokensTag is not applicable for the arguments (Object)
1. 问题 看到这个错误以为是貌似jsp页面有误,c:forTokens标签用错了?? An error occurred at line: in the jsp file: /WEB-INF/pag ...
- The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the arguments (int, SettingFragment, String)
The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the ...
- The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (new View.OnClickListener(){}, String, int)
package comxunfang.button; import android.support.v7.app.ActionBarActivity; import android.os.Bundle ...
- 自己写的demo。List<HashMap<String,Object>>=new ArrayList<HashMap<String,Object>>
package com.pb.collection; import java.util.ArrayList; import java.util.HashMap; import java.util.It ...
- 把List<Map<String,Object>>转成Map<String,Object>
Map<String, Object> parmMap = new HashMap<String, Object>(); //定义一个用于存储强转后的Map List<M ...
随机推荐
- [转帖]阿里的JDK预热warmup过程
预热warmup过程 https://blog.csdn.net/wabiaozia/article/details/82056520 Jwarmup 原理是记录上一次运行时已经变成native co ...
- dict字典
dict字典 字典的概述 • 概述:使⽤键-值(key-value)⽅式存储. • key的特点: • 1.字典中的key必须是唯⼀的 • 2.key值必须是不可变的数据类型:字符串.元组.Numbe ...
- 烧脑!CMU、北大等合著论文真的找到了神经网络的全局最优解
烧脑!CMU.北大等合著论文真的找到了神经网络的全局最优解 机器之心 已认证的官方帐号 811 人赞同了该文章 选自arXiv,作者:Simon S. Du.Jason D. Lee.Haochu ...
- ASM实例修改SYS密码
修改ASM实例中SYS用户密码 How To Change ASM SYS PASSWORD ? (文档 ID 452076.1) Oracle Database - Enterprise Editi ...
- 修改win7 iis上传文件大小限制200KB
win7 iis 修改上传限制,需要修改2个地方: 1,“双击“Internet 信息服务(IIS)管理器”中的“ASP”– 打开“配置 ASP 应用程序的属性”–展开“限制属性”:修改“最大请求实体 ...
- regarding-hsts-in-netscaler
regarding-hsts-in-netscaler 参考: Strict Transport Security (STS or HSTS) with Citrix NetScaler and Ac ...
- Python实现FTP文件定时自动下载
之前遇到技术问题总能在技术博客上得到启发,十分感谢各位的无私分享.而自己却很少发文,固然是水平有限,但也限制了知识积累和总结.今后多总结分享,回馈博客的同时也希望大家多多批评. 一.需求: 某数据公司 ...
- vue去哪儿网项目环境配置
一.首先安装node.js 根据自己的(windows或mac)系统进行安装node,在开发环境中一般安装LTS版本.安装成功后,在终端输入"node -v"和"npm ...
- Go 字符串使用
Go语言中的字符串 Go 中的字符串是兼容 Unicode 编码的,并且使用 UTF-8 进行编码,这样每一个Unicode字符根据代码点的大小使用1.2.3或4个字节表示代码点.Go 语言中的字符串 ...
- 关于NSOperationQueue,一个容易让初学者误解的问题
凡是学习NSOperationQueue的人,都会遇到setMaxConcurrentOperationCount这个函数.在网上的许多博文中,都将setMaxConcurrentOperationC ...