如何使用java中的对象

来源:互联网 发布:百度小号批发淘宝 编辑:程序博客网 时间:2024/06/14 15:57

创建对象

类名 对象名=new 类名();Telphone phone=new Telphone;

java对象
在程序中使用对象
这里写图片描述

package newStudy;public class InitailTelphone {    public static void main(String[] args) {        // TODO Auto-generated method stub        Telphone phone=new Telphone();        //调用对象的方法        phone.sendMessage();        //给属性(实例变量)赋值        phone.screen=5.2f;        phone.cpu=1.4f;        phone.mem=64f;        //调用对象的方法        phone.sendMessage();    }}
0 0
原创粉丝点击