简体   繁体   中英

What does '…' mean in java?

I'm a newbie learning about java. And I have a question to ask. Here is a simple code.

double diameter = ...;
double circumference = 3.14 * diameter;

I really don't understand what '...' means. In my opinion, it might be something which is used for abbreviating the code. Am I right?

As Thomas Jungblut mentioned, this is not valid Java code, and is merely the author letting you know that you can pick any double value.

More generally, if you want to know whether something is valid Java code in a book example, the easiest way is to just write a main method, stick the code in there, and see if it compiles.

As said this is not a valid java code, however if it was in arguments of a function like this :

public void myMethod(String... strings){
// method body

}

It means that zero or more String objects (or an array of them) may be passed as the parameter(s) for that function.

Have a great day,

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