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

hello2.screen=6.0f与hello2.screen(6.0f)区别

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


正在回答

3 回答

hello2.screen=6.0f是对属性进行赋值,而

hello2.screen(6.0f)是调用screen方法了


3 回复 有任何疑惑可以回复我~

hello2.screen是直接对属性进行赋值。hello2.screen是当screen为private是不能直接赋值,必须通过方法来。

0 回复 有任何疑惑可以回复我~

用hello2.getscree(6.0f)赋值 还要看Telephone类中 属性 scree前的修饰符 如果是 prinvae 就不能用hello2.screen(6.0f)赋值 要用get      如果是public 就可以用hello2.scree(6.0f)赋值

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

hello2.screen=6.0f与hello2.screen(6.0f)区别

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号