今天,我弟遇到一个有意思的错误~

程序:

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的更多相关文章

  1. The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (GameV

    在当前短信内容的activity中写            Bundle bun = new Bundle();         bun.putString("message",  ...

  2. 错误: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 ...

  3. 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 ...

  4. The method setOnClickListener(View.OnClickListener) in the type View is not applicable

    开始学习 android 了,学习的是高明鑫老师的android视频教程(android视频教学). 学到第八讲时, 在写动态设置时报错: The method setOnClickListener( ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 自己写的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 ...

  9. 把List<Map<String,Object>>转成Map<String,Object>

    Map<String, Object> parmMap = new HashMap<String, Object>(); //定义一个用于存储强转后的Map List<M ...

随机推荐

  1. (五)Respose 知识点总结 (来自那些年的笔记)

    目录 HttpServletResponse简介 向客户机写数据 HttpServletResponse应用 打印中文,让浏览器显示不乱码 : 下载文件 输出随机图片(验证码) 不要缓存 图片的src ...

  2. Python之对象持久化笔记

    pickle 序列化为字符串 .dumps(obj): 将对象序列为字符串 .loads(s): 从字符串反序列化对象 例如 import pickle person = {'name': 'Tom' ...

  3. 使用Duilib开发Windows软件(2)——控件的基本介绍

    XML 先学习xml https://www.w3cschool.cn/xml/xml-xml-tutorialhc4o1t5m.html 控件 上图是我们下载的NIM_Duilib_Framewor ...

  4. BFS练习

    1. 给定$d,k$, 求最小的被$d$整除, 且各数位仅有$k$和$0$组成的数. $(1\le k\le 9,1\le n\le 1e6)$ 从高位到低位$BFS$, BFS求出字典序最小的方案. ...

  5. 将迁移学习用于文本分类 《 Universal Language Model Fine-tuning for Text Classification》

    将迁移学习用于文本分类 < Universal Language Model Fine-tuning for Text Classification> 2018-07-27 20:07:4 ...

  6. (四)Activiti之流程定义部署之ZIP方式和流程定义查询

    一.流程定义部署之ZIP方式 上一章节我们使用classpath的方式加载流程定义文件,这里我们使用ZIP的方式. 1.1 用activiti插件生成bpmn和png图片之后,压缩到一个zip格式的压 ...

  7. MySql8.0 安装重要的两步。

    1.去官网下载mysql社区版 windows安装包. 2.在安装包 安装的过程中,有一步就是启动mysql 会失败: 然后修改服务后,再次回到安装界面点击:execute,就会成功了. 先去配置一下 ...

  8. springboot启动流程(十)springboot自动配置机制

    所有文章 https://www.cnblogs.com/lay2017/p/11478237.html 正文 在第七篇文章中我们了解到,refresh过程将会调用ConfigurationClass ...

  9. 【多进程】php实现 master-worker 守护多进程模式

    <?php class Worker{ public static $count = 2; public static function runAll(){ static::runMaster( ...

  10. js大数计算之计算

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...