编译出现unchecked call to add(E)的警告问题怎么解决?高手快进来,非常感谢!

jane_zhao 2007-07-10 12:08:02
我编译时出现:
Note:Sam.java uses unchecked or unsafe operations.
Note:Recompile with -Xlint:unchecked for details.
我Recompile了以后,出现的警告是:
warning:[unchecked]unchecked call to add(E) as a member of the raw
type java.util.ArrayList
al.add(Double.valueOf(in));

其中:
static ArrayList al=new ArrayList();
double in;

请教各位高手了,非常感谢!
...全文
4092 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
如果你不想改 al 的话,需要在方法声明的上一行加上

@SuppressWarnings("unchecked")

不让编译器进行检查,但不推荐这样做。
  • 打赏
  • 举报
回复 1
类型安全检查,JDK 1.5 的集合警告,你准备在 al 里面放什么呢,如果是 String 的话就改成:

static ArrayList<String> al=new ArrayList<String>();

总之在 <> 里放进去你需要存放的类的名字就可以了。
NCro 2007-07-10
  • 打赏
  • 举报
回复
Eclipse里Compiler的配置里面有,可以忽略掉
约翰羊 2007-07-10
  • 打赏
  • 举报
回复
楼主可以结贴了
jyh149129 2007-07-10
  • 打赏
  • 举报
回复
顶1楼!
看看jdk1.5的泛型就明白了
ll42002 2007-07-10
  • 打赏
  • 举报
回复

rainv 2007-07-10
  • 打赏
  • 举报
回复
mark
interpb 2007-07-10
  • 打赏
  • 举报
回复
static ArrayList<Double> al=new ArrayList<Double>();
fengmingjie 2007-07-10
  • 打赏
  • 举报
回复
因为它不能够确信加入到list中的值具有正确的类型。意思是使用了一个未经处理的类型,它不能验证代码是类型安全的。
jane_zhao 2007-07-10
  • 打赏
  • 举报
回复
楼上的,你好,谢谢你!

我想给al里存放Double型数据。
au3反编译源码 myAut2Exe - The Open Source AutoIT Script Decompiler 2.9 ======================================================== *New* full support for AutoIT v3.2.6++ :) ... mmh here's what I merely missed in the 'public sources 3.1.0' This program is for studying the 'Compiled' AutoIt3 format. AutoHotKey was developed from AutoIT and so scripts are nearly the same. Drag the compiled *.exe or *.a3x into the AutoIT Script Decompiler textbox. To copy text or to enlarge the log window double click on it. Supported Obfuscators: 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.14 [June 16, 2007]' , 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.15 [July 1, 2007]' , 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.20 [Sept 8, 2007]' , 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.22 [Oct 18, 2007]' , 'Jos van der Zande AutoIt3 Source Obfuscator v1.0.24 [Feb 15, 2008]' , 'EncodeIt 2.0' and 'Chr() string encode' Tested with: AutoIT : v3. 3. 0.0 and AutoIT : v2.64. 0.0 and AutoHotKey: v1.0.48.5 The options: =========== 'Force Old Script Type' Grey means auto detect and is the best in most cases. However if auto detection fails or is fooled through modification try to enable/disable this setting 'Don't delete temp files (compressed script)' this will keep *.pak files you may try to unpack manually with'LZSS.exe' as well as *.tok DeTokeniser files, tidy backups and *.tbl (<-Used in van Zande obfucation). If enable it will keep AHK-Scripts as they are and doesn't remove the linebreaks at the beginning Default:OFF 'Verbose LogOutput' When checked you get verbose information when decompiling(DeTokenise) new 3.2.6+ compiled Exe Default:OFF 'Restore Includes' will separated/restore includes. requires ';

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧