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 ...
随机推荐
- 电子防抖(EIS)无效的相关修改
[DESCRIPTION] 电子防抖(EIS)无效的相关修改 [SOLUTION] 电子防抖(EIS)无效,根据不同的版本,可以先查看是否已经做了相关修改.1. MT6580/MT6735平台请参考如 ...
- PS错误1
PS错误1 提示要卸载.不用卸载直接安装即可.还保留了之前的设置. 在安装目录下看看有没有安装PS的exe程序.可能有.
- 【Pandas数据分析案例】2018年北京积分入户情况分析
据说,北京落户的难度比加入美国国籍还高.而北京2018年首次实行积分入户制,让我们来分析一下首批通过积分入户拿到北京户口的数据. 首先从北京积分落户官网下载公示名单: 根据表格中的信息,我们主要从以下 ...
- go 函数 命名返回值
Go 的返回值可以被命名,并且像变量那样使用. 返回值的名称应当具有一定的意义,可以作为文档使用. 没有参数的 return 语句返回结果的当前值.也就是`直接`返回. 直接返回语句仅应当用在像下面这 ...
- 如何在 arm 官网上找到合适的手册
http://infocenter.arm.com/help/advanced/help.jsp 在这里输入合适的版号即可 这样就可以不用去 CSDN 了 100000_0000_00_EN - AR ...
- 基于搜索的贝叶斯网络结构学习算法-K2
基于搜索的贝叶斯网络结构学习算法-K2 2018-04-05 19:34:18 ItsBlue 阅读数 3172更多 分类专栏: 贝叶斯网络 网络结构学习 版权声明:本文为博主原创文章,遵循CC ...
- 【原创】大叔经验分享(93)centos安装oracle客户端
1 下载客户端 官方下载地址:https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.ht ...
- opencv中自适应阈值函数的实现(c++)
根据<面向飞机蒙皮接缝的线结构光检测技术研究_张卡>论文中的原理,编写了自适应阈值函数 原理: //计算灰度最大最小值 void MaxGrayValue(Mat image,int &a ...
- Go part 4 数据容器(数组,slice,string,map,syncMap,list)
数组 数组是值类型,因此改变副本的值,不会影响到本身 数组的定义:var 变量名 [元素数量] T 变量名(符合标识符要求即可) 元素数量(整型,可以是const中的值) T(可以是任意基本类型,包括 ...
- JS中的兼容性问题
事件对象兼容 window.event只能在IE下运行,而不能在Firefox下运行,这是因为Firefox的event只能在事件发生的现场使用.Firefox必须从源处加入event作 ...