전체 글
-
chapter2) 배열 요소의 합계 구하기PS/etc 2020. 7. 7. 19:27
public class Q3 { public static void main(String[] args) { Random random = new Random(); int[] arr = new int[random.nextInt(10)]; for (int i = 0; i < arr.length; i ++) { arr[i] = random.nextInt(100); System.out.print(arr[i] + " "); } int sum = sumOf(arr); System.out.println("\n배열 요소의 총 합계 : " + sum); } static int sumOf(int[] arr) { int sum = 0; for (int i = 0; i < arr.length; i++) { sum += arr[i..
-
chapter2) 배열 역순 정렬PS/etc 2020. 7. 7. 19:18
public class Q2 { public static void main(String[] args) { Random random = new Random(); int[] arr = new int[6]; for (int j = 0; j < arr.length; j++) { arr[j] = random.nextInt(100); System.out.print(arr[j] + " "); } for (int i = 0; i < arr.length/2; i++) { System.out.println("\na[" + i + "]과 a[" + (arr.length - 1 - i) + "]를 교환합니다."); swap(arr, i, arr.length - i - 1); for (int j = 0; j < arr.leng..
-
외부설정 - 2부Spring 2020. 7. 7. 16:26
외부설정을 Bean으로 사용하기 Class 생성후 @Component 등록 @ConfigurationProperties("key") 선언후 getter,setter 설정 위 의존성을 추가해줘야 사용가능 사용할 때는 @Value가 아닌 빈을 주입받아서 .getXXX 메소드로 사용 융통성 있는 바인딩 - context-path (케밥) - context_path (언더스코어) - contextPath (캐멀케이스) - CONTEXTPATH 모두 properties에서 지원한다. Duration Type 컨버젼 application.properties 안에 있는 키, 값들은 사실 모두 문자열 형태로 존재하지만, Bean 으로 등록되는 클래스와 바인딩될 때, String, int, Duration 등으로 모두 ..
-
외부 설정 - 1부Spring 2020. 7. 7. 15:35
외부 설정 파일 - 애플리케이션에서 사용하는 여러가지 설정 값들을 애플리케이션의 밖이나 안에 정의할 수 있는 기능이다. 사용할 수 있는 외부 설정 - properties - YAML - 환경변수 - 커맨드 라인 아규먼트 application.properties는 기본적으로 key-value값이고, 스프링 부트가 애플리케이션을 구동할 때 자동으로 로딩하는 파일이다. 외부설정을 사용하는 방법 - application.properties에 입력한 값을 @Value로 사용 가능하다. - Environment 객체를 가져와 .getProperty("key) 메서드로 사용 가능하다. 테스트에서의 외부 설정 - 테스트 실행시 main -> test 순서로 프로젝트를 빌드, test 에 있는 파일들이 main 에 있는..
-
chapter1) 직각 이등변 삼각형 별찍기PS/etc 2020. 7. 6. 22:10
public class Q15 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("직각 이등변 삼각형을 출력합니다."); System.out.print("출력할 단수 : "); int n = scanner.nextInt(); System.out.println("출력하고 싶은 삼각형을 입력하세요."); System.out.println("LB LU RB RU"); System.out.print("출력할 삼각형 : "); String triangle = scanner.next(); if (triangle.contains("LB")) { triangleLB(n); } else..