| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
- java테스트
- Eclipse
- IntelliJ
- Java
- 테스트자동화
- 인텔리제이
- 배열
- 문자열
- javascript
- html
- 스프링부트
- Array
- ArrayList
- junit5
- js
- input
- 단위테스트
- SpringBoot
- string
- list
- 자바문법
- 자바
- Visual Studio Code
- junit
- vscode
- 자바스크립트
- HashMap
- math
- CSS
- 정규식
- Today
- Total
목록MAX (4)
어제 오늘 내일
Math.max()와 Math.min()은 두 수를 비교해 각각 더 큰 값, 더 작은 값을 반환하는 메소드입니다.자료형에 따라 오버로드가 되어 있어 다양한 기본 타입에서 사용할 수 있습니다. 1. 기본 사용법public class MathMaxMinBasic { public static void main(String[] args) { System.out.println(Math.max(3, 7)); // 7 System.out.println(Math.min(3, 7)); // 3 System.out.println(Math.max(-10, -5)); // -5 System.out.println(Math.min(-10, -5)); // -10 ..
List의 값 중 최대값, 최소값을 구하기 위해서, 다음 메소드를 사용할 수 있습니다. Collections.max() Collections.min() ArrayList에서 최대값, 최소값 구하기 public static T max(Collection
배열이 가지고 있는 원소 중, 가장 큰 값(최대값), 가장 작은 값(최소값)을 구하는 방법을 소개합니다. 최대값 구하기 코드 public class Max { public static void main(String[] args) { int[] arr = { 3, 2, 1, 5, 1 }; // 최대값 초기값 세팅 int max = arr[0]; // 최대값 구하기 for (int num : arr) { if (num > max) { max = num; } } // 최대값 출력 System.out.println(max); } } 결과 5 int max = arr[0]; 배열의 첫번째 값을 최대값(max)의 초기값으로 설정하였습니다. for(int num : arr) { ... } 배열을 순회하면서 max에 ..
Javascript 배열의 여러 원소들 중 최대값, 최소값을 구하는 방법을 정리합니다. 1. Math.max(), Math.min() 소개 2. Function.prototype.apply() 사용하기 3. Spread Operator(전개 연산자) 사용하기 1. Math.max(), Math.min() 소개 const maxValue = Math.max(1, 2, 3, 4, 5); const minValue = Math.min(1, 2, 3, 4, 5); document.write('Max : ' + maxValue); document.write(' '); document.write('Min : ' + minValue); Math.max()와 Math.min() 함수는 파라미터로 입력받은 숫자들 중 최..