简体   繁体   中英

Why i have array [] option as consturctor invoke?

I have a class for example GooglePlayConnection. When I create object of this class without variable initialization (just to invoke method) new GooglePlayConnection() IDEA suggest to me 2 options: like default empty constructor () and .. array []? What does it mean?

在此处输入图片说明

I don't have any constructors in these classes.

You don't have to provide any constructors for your class, but you must be careful when doing this. The compiler automatically provides a no-argument, default constructor for any class without constructors.

https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html

...and .. array []? What does it mean?

It's to create a GooglePlayConnection array :

GooglePlayConnection[] connections = new GooglePlayConnection[10];
connections[0] = new GooglePlayConnection(/*...*/);
// ...

or

GooglePlayConnection[] connections = new GooglePlayConnection[] {
    new GooglePlayConnection(/*...*/),
    // ...
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM