void 表示这个方法不会返回任何值。例如,如果你想声明一个名为 printHello 的方法,可以这样写:public static void printHello() { System.out.println("Hello!");} 这个方法可以被任何地方调用,它不需要任何参数,并且不会返回任何值。它只是在被调用时输出一行字符串。
因为他没有返回值。这和‘返回值为void’有极大的差别。返回void时,一般函数并不返回任何东西,但是一...
注意:构造方法没有返回值,所以也就没有return 。 2.在实例化对象的时候其实调用的就是构造方法 public class Test01{ public Test01(){ System.out.println("构造方法被调用了~~~"); } public static void main(String[] args ){ Test01 t = new Test01(); } } 1. 2. 3. 4. 5. 6. 7. 8....