免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2636 | 回复: 1
打印 上一主题 下一主题

:[unchecked] 对作为普通类型 java.util.ArrayList 的成员的 ad [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-01-09 17:12 |只看该作者 |倒序浏览
代码

  1. import java.io.FileOutputStream;
  2. import java.io.PrintWriter;
  3. import java.util.ArrayList;

  4. public class logTex {
  5.         ArrayList aList = new ArrayList();
  6.        
  7.        
  8.         public void setTex(String str){
  9.                 aList.add(str);
  10.                 System.out.println(str);
  11.         }
  12.         public void getTex(String str){
  13.                 try{
  14.                     PrintWriter pw = new PrintWriter(new FileOutputStream(str));
  15.                     System.out.println(str);
  16.                     System.out.println("aList Size: "+aList.size());
  17.                     for (int i=0; i<aList.size(); i++){
  18.                                 pw.println(aList.get(i));
  19.                                
  20.                     }
  21.                     pw.flush();
  22.                     pw.close();
  23.                 }catch(Exception e){
  24.                         e.printStackTrace();
  25.                 }
  26.         }
  27.         /**
  28.          * @param args
  29.          */
  30.         public static void main(String[] args) {
  31.                 // TODO Auto-generated method stub
  32.                 logTex tx = new logTex();
  33.                 for(int i=0; i<10; i++){
  34.                         tx.setTex("测试"+i);
  35.                        
  36.                 }
  37.                 tx.getTex("s3.txt");
  38.         }

  39. }


复制代码


显示:

D:\74>javac logTex.java -Xlint:unchecked
logTex.java:10: 警告:[unchecked] 对作为普通类型 java.util.ArrayList 的成员的 ad
d(E) 的调用未经检查
                aList.add(str);
                         ^

请问如何解决?

论坛徽章:
0
2 [报告]
发表于 2007-01-09 18:15 |只看该作者

明白了

private ArrayList<String> aList = new ArrayList<String>();
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP