weixin_54596215
2021-01-16 17:08study方法中的comp.brand该怎么理解呢?
package MyPro004;
/**
*
*
* @author
*
*/
public class Student {
//属性
int id;
String name;
int age;
Computer comp;
//方法
void play() {
System.out.println("我在玩游戏,王者荣耀!!");
}
void study() {
System.out.println("我在认真学习!!"+ comp.brand);
}
Student(){ //构造方法,用于创建这个类的对象,无参的构造方法可以由系统自动创建
}
//static Student a = new Student();
public static void main(String[] args) {
Student a = new Student();
a.id = 1001;
a.name = "高淇的Java课";
a.age = 18;
Computer c1 = new Computer();
c1.brand = "联想";
a.comp = c1;
a.play();
a.study();
}
}
class Computer {
String brand;
}
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- 救救小白,这个实参怎么回报错呢?
- python
- 开发语言
- 2个回答
- 调用某一个方法 报错NoSuchMethodError ?
- java
- 2个回答
- 如何使用jquery add函数添加动态数据?
- html
- javascript
- php
- jquery
- 1个回答
- 用PHP填充Flash CompressionAlgorithm.DEFLATE ByteArray
- actionscript
- php
- flash
- 1个回答
- 这行PHP代码有什么问题?
- runtime-error
- php
- 1个回答