每个程序里有且只有一个公共类,声明为public classname{} 在这个公共类中加程序的入口 public classname { public static void main(String[] args) { ...... } }
here is an example for you: public class MyTest { public MyTest(){ System.out.println("construct MyTest"); ClassLoader myClassLoader = ClassLoader.getSystemClassLoader(); System.out.println(">>>>>dumping system class loader >>>>>\n" + myClassLoader.toString()); System.out.println(">>>>>resource >>>>>\n" + myClassLoader.getSystemResource("MyTest.class")); System.out.println(">>>>>getResources(String name) >>>>>\n" + myClassLoader.getResource("MyTest.class"));
}
public static void main(String argv[]) { MyTest test = new MyTest(); System.out.println("I have test my class MyTest, haha!"); } }
public static void main(String args[])是整个程序的入口,执行程序时首先读(String args[])这个字符串,public static 是对程序的访问符,这是编译器预定义的,查一下入门书籍就搞定拉。
在这个公共类中加程序的入口
public classname
{
public static void main(String[] args)
{
......
}
}
public class MyTest
{
public MyTest(){
System.out.println("construct MyTest");
ClassLoader myClassLoader = ClassLoader.getSystemClassLoader();
System.out.println(">>>>>dumping system class loader >>>>>\n" + myClassLoader.toString());
System.out.println(">>>>>resource >>>>>\n" + myClassLoader.getSystemResource("MyTest.class"));
System.out.println(">>>>>getResources(String name) >>>>>\n" + myClassLoader.getResource("MyTest.class"));
}
public static void main(String argv[]) {
MyTest test = new MyTest();
System.out.println("I have test my class MyTest, haha!");
}
}
http://javaclub.3322.org
http://www.ChinaJavaWorld.com
http://www.java.com.cn
http://www.java-cn.net 国外:
http://java.sun.com
http://www.apache.org
http://www-106.ibm.com/developerworks
http://www.javaworld.com
http://www.javapro.com
http://theserverside.com
http://java.isavvix.com
http://www.jguru.com
http://www.jars.com
http://developer.netscape.com
http://technet.oracle.com
http://www.bea.com
http://www.componentsource.com/java
http://www.sys-con.com/java
http://www.javaxforum.com/index.php
http://www.javaranch.com
http://dev2dev.bea.com.cn
http://www.javaresearch.org
http://www.theserverside.com
http://www.javacoder.net
http://www.onjava.com
http://www.jspinsider.com
http://www.ejbnow.com
http://www.javajia.com
http://www.huihoo.com