📄 constructor.java~39~
字号:
package Constructor;class ConstructorTest { private int x; private double y; private boolean z; private char c='k'; ConstructorTest(){ // 定义 没有 参数 的 构造方法 x=1; y=0.1; } ConstructorTest(int x){ //x=34; this.x=x; } ConstructorTest(double y){ this.y=y; } ConstructorTest(int x,double y){ this.x=x; this.y=y; } ConstructorTest(boolean z){ this.z=z; } ConstructorTest(char c){ this.c=c; //c='m'; } void show(){ System.out.println("x="+x+" y="+y+" z="+z+" c="+c); }}public class Constructor{ public static void main(String[] args){ ConstructorTest co1=new ConstructorTest(); ConstructorTest co2=new ConstructorTest(3); ConstructorTest co3=new ConstructorTest(9.0); ConstructorTest co4=new ConstructorTest(5,5.9); ConstructorTest co5=new ConstructorTest(true); ConstructorTest co6=new ConstructorTest('h'); co1.show(); co2.show(); co3.show(); co4.show(); co5.show(); co6.show(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -