JAVA-对象的使用

image

package com.itheima;

public class phonedemo01 {
    public static void main(String[] args) {
        //格式
        phone p = new phone();
        //使用成员变量
        System.out.println(p.brang);
        System.out.println(p.price);
        p.brang="小米";
        p.price=2999;
        System.out.println(p.brang);
        System.out.println(p.price);

        //使用成员方法
        p.call();
        p.message();

    }
}

```执行结果
```java
null
0
小米
2999
打电话
发短信

Process finished with exit code 0
posted @ 2022-11-07 22:05  NiceTwocu  阅读(15)  评论(0编辑  收藏  举报