简体   繁体   English

为什么我有数组 [] 选项作为构造函数调用?

[英]Why i have array [] option as consturctor invoke?

I have a class for example GooglePlayConnection.我有一个类,例如 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 []?当我在没有变量初始化的情况下创建这个类的对象时(只是为了调用方法) new GooglePlayConnection() IDEA 向我建议了 2 个选项:比如默认的空构造函数 () 和 .. 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 https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html

...and .. array []? ...和..数组[]? What does it mean?这是什么意思?

It's to create a GooglePlayConnection array :这是创建一个GooglePlayConnection数组

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

or或者

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果在异常上调用getCause(),为什么还要处理Throwable - Why do I have to deal with Throwable if I invoke getCause() on an Exception 为什么我不能在数组类型 int[][] 上调用这个方法 - Why can I not invoke this method on an array type int[][] 为什么我观察到了球的动量,尽管我已经写了frame.repaint()从循环中调用paintComponent()方法 - why the movemet of ball is observerd although i have wriiten frame.repaint() to invoke paintComponent() method from the loop 为什么SSLSocket写入选项没有超时? - Why SSLSocket write option does not have timeout? 为什么子类必须在超类中调用no args构造函数? - why does the subclass have to invoke the no args constructor in the super class? 为什么InvocationHandler中的方法invoke()有一个参数Object proxy? - why does the method invoke() in InvocationHandler have an parameter Object proxy? 为什么我不能提示用户变量是数组大小? - Why can't I have a user prompted varaible be the array size? 为什么我必须在Split方法中使用Array.toString? - Why do I have to use Array.toString at Split method? 我将如何在Java中调用数组参数? - How will i invoke the array parameters in java? 为什么反射调用方法需要将varargs包装在数组中? - Why reflection invoke method require varargs to be wrapped in array?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM