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 ...
随机推荐
- python学习-15 基本数据类型4
1.range a = range(0 ,100 , 5) #创建>=0,<100的连续数字,步长为5 for b in a: print(b) 运算结果: 0 5 10 15 20 25 ...
- Spring @Transactional注解在什么情况下会失效,为什么?
出处: https://www.cnblogs.com/hunrry/p/9183209.html https://www.cnblogs.com/protected/p/6652188.htm ...
- java 获取json字符串中key对应的值
用到了Gson的JsonParser maven项目引入 <dependency> <groupId>com.google.code.gson</groupId> ...
- Manacher算法+注释
Manacher算法是用来求一个字符串中最长回文串的算法. 考虑暴力求最长回文串的做法: 暴力枚举字符串中的所有字串判断是否回文,然后求最大值. 时间复杂度O(n^3),考虑优化. 我们从枚举所有字串 ...
- Unity插件研究-EasyTouch V5
抽空研究了下Easy Touch 5插件,发现确实很好用,下面是相应的用法: 1. Easy Touch Controls:实现虚拟摇杆的组件 在项目的"Hierarchy"窗口下 ...
- Unity性能优化-DrawCall
1. DrawCall是啥?其实就是对底层图形程序(比如:OpenGL ES)接口的调用,以在屏幕上画出东西.所以,是谁去调用这些接口呢?CPU.比如有上千个物体,每一个的渲染都需要去调用一次底层接口 ...
- 关于spring中配置文件路径的那些事儿
在项目中我们经常会需要读一些配置文件来获取配置信息,然而对于这些配置文件在项目中存放的位置以及获取这些配置文件的存放路径却经常搞不清楚,自己研究了一下,记录下来以备后用. 测试代码如下 package ...
- (九)easyUI之选项卡
前台 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncodi ...
- Node初始以及环境搭建(Node01)
1. 相关概念 •什么是JavaScript? •一种遵守ECMAScript标准的脚本语言 •最初只能运行在浏览器端 •浏览器中的 JavaScript 可以做什么? •操作DOM:表单验证.动画 ...
- C#工厂模式案例
class JianDanGongChang { static void Main(string[] args) { Factory factory=new LianXiangFactory(); D ...