为了账号安全,请及时绑定邮箱和手机立即绑定

Java 中的小问题 初学者

Java 中的小问题 初学者

Bin_X 2015-01-25 15:54:04
    public static void main(String[] args){                //在 main 方法中调用 print 方法        HelloWorld test=new HelloWorld();        test.print();中的HelloWorld test=new HelloWorld();这句是起什么作用的额? 谢谢
查看完整描述

1 回答

已采纳
?
_Exception

TA贡献18条经验 获得超9个赞

test 中得到 HelloWorld 对象, test.print(); 调用 HelloWorld 对象的 print() 方法, 在同一个类中 你把 print() 方法 改成 static 静态的, 就不用  HelloWorld test=new HelloWorld(); 了  , 在 main 方法中 可以 print();这样直接调用

查看完整回答
反对 回复 2015-01-25
  • Bin_X
    Bin_X
    先感谢你哈 我先去把对象 类 这一块再看看,之前跟着视频走的 ,没看书
  • _Exception
    _Exception
    还有方法 ,
  • Bin_X
    Bin_X
    非常感谢!
  • 1 回答
  • 0 关注
  • 1416 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信