package hello;
public class Hello{ //创建一个类叫做Hello
int length;//字段
int width;
public Hello(int length ,int width) {
this.length=length;//在构造方法中的局部变量中使用了属性/字段变量的内存进行赋值
this.width =width;//同理
}
public static void main(String[] args) {
Hello a = new Hello(10,20);
System.out.println(a.length);//length:10
}
}
12-14
134
11-29
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交