Java中的对象

2017-02-04  本文已影响12人  by小杰

使用对象的步骤:
1、创建对象
类名 对象名 = new 类名();
TestClass phone = new TestClass();
2、使用对象
引用对象的属性:对象名.属性
引用对象的方法:对象名.方法名()

public class InitailTelephone {

    public static void main(String[] args) {

        TestClass test = new TestClass();
        test.screen = 100;
        test.cpu = 100;
        test.mem = 8;
        
        test.call();
        test.mesage();
        
    }

}```
上一篇 下一篇

猜你喜欢

热点阅读