1024programmer News 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

Technology Sharing
non-anonymous object
Technology Sharing

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


This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/java-anonymous-object/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

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
首页
微信
电话
搜索