本帖最后由 张华廷 于 2012-6-26 13:40 编辑
import java.util.*;
class CollectonsDemo2
{
public static void main(String[] args)
{
fillDemo();
}
public static void fillDemo()
{
List<String> list = new ArrayList<String>();
list.add("abcd");
list.add("aaa");
list.add("zz");
list.add("kkkk");
list.add("qq");
sop(list);
Collections.fill(list,"pp");
sop(list);
}
public static void sop(Object obj)
{
System.out.println(obj);
}
}
程序在eclipse中运行成功,结果:[abcd, aaa, zz, kkkk, qq]
[pp, pp, pp, pp, pp]
但是在dos命令行中运行时出现问题d:\Users\Administrator\Desktop\集合>java CollectionDemo2
Exception in thread "main" java.lang.NoClassDefFoundError: CollectionDemo2
Caused by: java.lang.ClassNotFoundException: CollectionDemo2
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: CollectionDemo2. Program will exit. |
|