/** * 功能描述: 可变参数 JDK5引入 * @Param: * @Return: * @Author: XinHai.Ma * @Date: 2020/12/5 22:41 */ public class ParamDemo { public static void test(int total, String...array) { StringBuffer sb = new StringBuffer(""); sb.append("参数个数:" + total); sb.append("参数: "); for(String str : array) { sb.append(str); sb.append("、"); } System.out.println(sb.toString()); } public static void main(String[] args) { test(4, "1", "2", "3", "4"); } }