Topic: 这是什么:Recompile with -Xlint:unchecked for details.

  Print this page

1.这是什么:Recompile with -Xlint:unchecked for details. Copy to clipboard
Posted by: qileroro
Posted on: 2005-03-29 16:42

照书上的例子做编译不成功,显示出:
有没有人解释一下?
Note: PrintingContainers.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
例子的源代码是:
import java.util.*;
public class PrintingContainers
{
  static Collection fill(Collection c) {
    c.add("dog");
    c.add("dog");
    c.add("cat");
    return c;
  }
  
  static Map fill(Map m) {
    m.put("dog","Bosco");
    m.put("dog","Spot");
    m.put("cat","Rags");
    return m;
  }

  public static void main(String[] args) {
    System.out.println(fill(new ArrayList()));
    System.out.println(fill(new HashSet()));
    System.out.println(fill(new HashMap()));
  }
};

2.Re:这是什么:Recompile with -Xlint:unchecked for details. [Re: qileroro] Copy to clipboard
Posted by: cwcjava
Posted on: 2005-03-29 16:51

那那代码我运行了啊
每问题啊
这是输出结果:
[dog, dog, cat]
[dog, cat]
{dog=Spot, cat=Rags}

我的QQ是:181413517 有问题再一起讨论啊

3.Re:这是什么:Recompile with -Xlint:unchecked for details. [Re: qileroro] Copy to clipboard
Posted by: why
Posted on: 2005-03-29 17:52

>javac -X
-Xlint Enable recommended warnings
-Xlint:{all,deprecation,unchecked,fallthrough,path,serial,finally,-deprecation
,-unchecked,-fallthrough,-path,-serial,-finally}Enable or disable specific warni
ngs
-Xbootclasspath/p:<path> Prepend to the bootstrap class path
-Xbootclasspath/a:<path> Append to the bootstrap class path
-Xbootclasspath:<path> Override location of bootstrap class files
-Djava.ext.dirs=<dirs> Override location of installed extensions
-Djava.endorsed.dirs=<dirs>Override location of endorsed standards path
-Xmaxerrs <number> Set the maximum number of errors to print
-Xmaxwarns <number> Set the maximum number of warnings to print
-Xstdout <filename> Redirect standard output

4.Re:这是什么:Recompile with -Xlint:unchecked for details. [Re: qileroro] Copy to clipboard
Posted by: qileroro
Posted on: 2005-03-30 14:18

我加了-Xlint参数,不行,看下面的错误,我用的是JDK1.5 ,请问是怎么回事呢?

PrintingContainers.java:16: warning: [unchecked] unchecked call to put(K,V) as a
member of the raw type java.util.Map
m.put("cat","Rags");
^
6 warnings

5.Re:这是什么:Recompile with -Xlint:unchecked for details. [Re: qileroro] Copy to clipboard
Posted by: why
Posted on: 2005-03-30 20:48

qileroro wrote:
我加了-Xlint参数,不行,看下面的错误,我用的是JDK1.5 ,请问是怎么回事呢?

PrintingContainers.java:16: warning: [unchecked] unchecked call to put(K,V) as a
member of the raw type java.util.Map
m.put("cat","Rags");
^
6 warnings

these are warnings, not errors.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923