-
전달인수가 정해지지 않은경우 사용법JAVA 2020. 4. 22. 10:35
package test01; public class test05 { public static int max(int... a) { //전달인수 갯수 만큼의 배열을 생성 System.out.println(a.length); int max = a[0]; for(int i=1; i<a.length; i++) if(max<a[i]) max = a[i]; return max; } public static void main(String[] args) { int c; c = max(50, 60,80, 60, 54, 60); System.out.println("입력값중 큰값은 : " + c + "입니다"); c = max(50, 60,80, 60, 54, 60, 56, 87, 69); System.out.println("입력값중 큰값은 : " + c + "입니다"); } }
'JAVA' 카테고리의 다른 글
상속 extends (0) 2020.05.06 배열출력 (0) 2020.05.06 오버로딩 (0) 2020.04.22 달력 캘린더 (0) 2020.04.22 super, this 구분 (0) 2020.04.22