Home > Java > Javagetting Started > What does [...] in java mean?

What does [...] in java mean?

王林
Release: 2020-09-15 17:20:30
forward
6134 people have browsed it

What does [...] in java mean?

... represents a variable-length parameter, which means that any number of parameters of this type can be passed into this position. Simply put, it is an array.

(Video tutorial recommendation: java course)

Code sample:

1. testPoints(7);  
2.        testPoints(7,9,11);  
3.        testPoints(new Integer[]{7,9,11});  
1.  public static void testPoints(Integer... itgr){  
2.        if(itgr.length==0){  
3.            System.out.println("没有Integer参数传入!");  
4.        }else if(itgr.length==1){  
5.            System.out.println("1个Integer参数传入!");  
6.        }else{      
7.            System.out.println("the input string is-->");  
8.            for(int i=0;i<itgr.length;i++){  
9.                System.out.println("第"+(i+1)+"个Integer参数是"+itgr[i]+";");  
 
1.1个Integer参数传入!  
2.the input string is-->  
3.第1个Integer参数是7;  
4.第2个Integer参数是9;  
5.第3个Integer参数是11;    
6.the input string is-->  
7.第1个Integer参数是7;  
8.第2个Integer参数是9;  
9.第3个Integer参数是11;
Copy after login

Related recommendations: java introductory tutorial

The above is the detailed content of What does [...] in java mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template