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 ...
随机推荐
- VLAN之间通信-三层交换机实现
1.打开三层交换机的命令行,配置VLAN和设置端口IP enable //进入特权模式 configure terminal //进入全局配置模式 ip routing //启动交换机的路由功能 vl ...
- (五)Respose 知识点总结 (来自那些年的笔记)
目录 HttpServletResponse简介 向客户机写数据 HttpServletResponse应用 打印中文,让浏览器显示不乱码 : 下载文件 输出随机图片(验证码) 不要缓存 图片的src ...
- malloc/free和new/delete详解与应用
C++面试经常会问到关于malloc/free和new/delete的区别,网上有不同版本的解释,这里总结下并加上个人理解和使用. 两者相同点 1.都可以申请动态堆内存. 两者不同点 1.new/de ...
- time模块/datetime模块/calendar模块
time模块时间的表示形式时间戳:以整型或浮点型表示⼀个时间,该时间以秒为单位,这个时间是以1970年1⽉1⽇0时0分0秒开始计算的. 导入time import time 1.返回当前的时间戳 no ...
- WUSTOJ 1237: 将八进制的字符串转换成等价的十进制字符串(Java)
1237: 将八进制的字符串转换成等价的十进制字符串 题目 输入八进制,输出十进制.更多内容点击标题. 分析 输入的八进制数有20位.已经超出了Integer.MAX_VALUE的范围,因此此 ...
- harbor关联k8s
第一步 在harbor上创建用户,项目,将用户添加到对应项目中,并赋予用户项目管理者或者开发人员权限,使其对镜像仓库有读写权限. 本次部署创建用户liusw,密码Lsw123456,邮箱8730017 ...
- hdu 6165
虽然题解上说缩点然后判断入度就可以了,然后比赛的时候瞎暴力过了. #include <iostream> #include <cstring> #include <str ...
- HTML 禁止复制文字
因为本人平时喜欢看网络小说,但是喜欢看的文通过正经网站或者app都需要收费,让人很是不爽,所以...总之,百度网盘上资源很多.但是问题来了,这些资源肯定不会是作者自己流出的,也不应该是网站或app流出 ...
- SVN 问题解决之 Working copy path does not exist in repository
同事的SVN更新时提示某个特定文件提示 Working copy path does not exist in repository svn更新会被这个错误打断,导致无法完全更新 删掉文件再更新仍然有 ...
- Node中的net模块提供的前端通信
Node中的net模块提供的前端通信 客户端 业务: 客户端现在要在终端输入内容,然后回车发送内容给服务器 解决: Node中提供了一个叫做 readline 的 模块用于读取命令行内容 [ 单行读取 ...