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 ... 
随机推荐
- java 微信开发的工具类WeChatUtils
			import com.alibaba.fastjson.JSONObject;import com.bhudy.entity.BhudyPlugin;import com.bhudy.service. ... 
- Django 1.8.2 admin 数据库操作按下保存按钮出错
			Django报错:Runtimeerror: generator raised StopIteration python版本太新不兼容照成,下载python3.6就行了 
- spring cloud微服务实践五
			本篇我们来看看怎么实现spring cloud的配置中心. 在分布式系统中,特别是微服务架构下,可能会存在许多的服务,每个服务都会存在一个或多个的配置文件.那怎么多的配置文件的管理就会成为一个大问题. ... 
- RDS for MySQL 逻辑备份文件恢复到自建数据库
			使用MySQL自带的 mysqldump 工具可以通过逻辑备份文件恢复数据库,本文将介绍详细的逻辑备份恢复数据库操作步骤. 说明 通过物理备份文件恢复到自建数据库请参见RDS for MySQL 物理 ... 
- Tomcat安装及其目录结构介绍
			Tomcat服务器是一个免费的开放源代码的Web应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP程序的首选. Tomcat的安装版本有绿色解压 ... 
- (四)lucene之文本域加权
			一.前言 1.1 应用场景 有时在搜索的时候,会根据需要的不同,对不同的关键值或者不同的关键索引分配不同的权值,让权值高的内容更容易被用户搜索出来,而且排在前面. 为索引域添加权是再创建索引之前,把索 ... 
- opencv-04--图像金字塔
			图像金字塔被广泛应用于各种视觉应用中.图像金字塔是一个图像集合,集合中图像都源于同一个原始图像,而且是通过对原始图像连续降采样获得,直到达到某个中止条件才停止降采样.(当然,降为一个像素肯定是中止条件 ... 
- java 框架-缓冲-Redis 2Jedis操作
			https://www.cnblogs.com/wlandwl/p/redis.html Redis介绍及Jedis基础操作 1.Redis简介 Redis 是一个开源(BSD许可)的,内存中的数 ... 
- Android Service的有关总结
			来自一位网友的评论 1.使用方式 startService 启动的服务 主要用于启动一个服务执行后台任务,不进行通信.停止服务使用stopService bindService 启动的服务 该方法启动 ... 
- es6中Array.from()
			Array.from()方法就是将一个类数组对象或者可遍历对象转换成一个真正的数组. 那么什么是类数组对象呢?所谓类数组对象,最基本的要求就是具有length属性的对象. 1.将类数组对象转换为真正数 ... 
