进行预习完成重载类的。
package lol; public class lol { int length; test() { System.out.println("无参构造函数"); length = 400; } test(int i) {//带参构造函数 System.out.println("绿道长度为 " + i + " 米"); length = i; } void info() { System.out.println("绿道长度为 " + length + " 米"); } void info(String str) { System.out.println(str + ": 绿道长度为 " + length + " 米"); } } package lol; public class lwl { public static void main(String[] args) { test t = new test(300); t.info(); t.info("重载方法"); new test(); } }
浙公网安备 33010602011771号