Home >Java >Javagetting Started >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;
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!