Java anonymous object

Java anonymous object

Java-Anonymous Object One anonymous object new Car().num = 5;Attribute has no meaning new Car().run(); method is meaningful i.e. it doesn’t make sense to use properties of anonymous objects And it makes sense to use its methods How to use: When the method of an object is only called once, it can be done with an anonymous object, which is simpler If you call a member of an object, you must give the object a name 2 Below are two pictures Non-anonymous objects Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger’s permission. Java-Anonymous Object

java anonymous object

java anonymous object

Java-Anonymous Object An anonymous object new Car().num = 5; attribute has no meaning new Car().run(); method makes sense Even using properties of anonymous objects doesn’t make sense And it makes sense to use its methods How to use: When the method on the object is called only once, it can be done with an anonymous object, which is simpler If you call a member of an object, you must give the object a name Two Below are two pictures non-anonymous object Copyright statement: This article is an original article of the blogger, and shall not be reproduced without the permission of the blogger. Java-Anonymous Object

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索