Home  >  Q&A  >  body text

java - 请问在main方法中写成对象名.属性()并赋值,与直接参参数赋值输错误是什么原因?

在类Telphone属性设置为public screen中,在main方法中写成对象名.属性()即hello2.screen=6.0f是对screen赋值,能输出结果;但是写成hello2.screen(6.0f)就不对,显示错误,请问这是什么原因,这两者有什么区别?

大家讲道理大家讲道理2743 days ago584

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 10:52:36

    For variables, the equal sign is an assignment operation. The following writing method is to call a method called screen with a float parameter. Of course, if you don’t have this method, an error will be reported.

    reply
    0
  • Cancelreply