亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

代碼
提交代碼
public class VariableParameter1 { public void search(int element, int... elements) { boolean existed = false; for (int e: elements) { if (e == element) { existed = true; break; } } if (existed) { System.out.println("找到元素:" + element); } else { System.out.println("未找到元素:" + element); } } public static void main(String[] args) { // 創建對象 VariableParameter1 obj = new VariableParameter1(); // 調用方法 obj.search(2, 1,2,3,4); // 定義數組參數 int[] arr = {1,2,3,4}; // 將數組傳遞給可變參數列表 obj.search(2, arr); } }
運行結果