从这里引用:
A “Driver class” is often just the class that contains a main. In a
real project, you may often have numerous “Driver classes” for testing
and whatnot, or you can build a main into any of your objects and
select the runnable class through your IDE, or by simply specifying
“java classname.”
例:
这不是驱动程序类,因为它不包含任何main方法.在这种情况下,它有“hello”方法:
public class HelloWorld {
public void hello() {
System.out.println("Hello, world!");
}
}
与这一个 – 这是一个驱动程序类,因为它包含一个main方法,并且是运行HelloWorld的类:
public class HelloWorldDriver {
public static void main(String[] args) {
HelloWorld sayhello = new HelloWorld();
sayhello.hello();
}
}
因此,名称“驱动程序类” – 作为类HelloWorldDriver“驱动”或更确切地说,控制类HelloWorld的实例化和使用.