2023-05-08 1. 방법 라이브러리 정보를 추가한다. /* 메이븐 */ com.fasterxml.jackson.core jackson-databind 2.12.3 /* 그레이들 */ dependencies { implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.3' } @JsonInclude 어노테이션을 import 합니다. import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude 어노테이션을 DTO 클래스에 추가합니다. @JsonInclude(JsonInclude.Include.NON_NULL) public class MyDTO { private String name; pr..
2023-04-28 1. 원인 This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible. 이 예외는 객체의 동시 수정이 허용되지 않을 때 객체의 동시 수정을 탐지한 방법에 의해 발생할 수 있습니다. For example, it is not generally permissible for one thread to modify a Collection while another thread is iterating over it. In general, the results of the iteration are undefined ..
2023-03-24 1. 방법 우선 주어진 배열과 동일한 크기의 배열을 생성해 준다. 해당 주어진 배열을 1회 순회하며, 새로운 배열(sumArr)에 sumArr [i-1] + arr [i] 공식으로 대입해 주면 된다. 이후에 주어진 구간합을 구할때는 구간 끝 - 구간시작-1 공식을 이용하면 기존 배열을 다시 반복 순회하지 않아도 답을 도출할 수 있다. static int [] sumArr; @Test public void test(){ int [] arr = new int [] {4,5,13,43,22,1,5,7,8}; sumArr = new int [arr.length]; sumArr[0] = arr[0];//구간합 첫번째 인자 셋팅 //구간합 구하기 for(int i = 1; i < arr.leng..
2023-03-23 1. 방법 스택을 사용하면 해결을 할 수 있다. 주어진 숫자형 배열의 인덱스를 스택에 저장하고 각 인덱스 마다 비교하여 다음 큰 수를 찾을 수 있다. public int[] test(int[] numbers) { Stack stack = new Stack(); int[] answer = new int[numbers.length]; for (int i = 0; i 스택최상단인덱..
2023-03-17 1. 방법 방법은 각각의 rgb 값을 인터형으로 받아 문자열 format을 이용해 변경해 주면 된다. public static String rgbToHex(int r, int g, int b) { if(r 255) r = 255; if(g 255) g = 255; if(b 255) b = 255; String hex = String.format("%02X%02X%02X", r, g, b).toUpperCase(); return hex; } 메인 이미지 출처 : 사진: Unsplash의Mona
2023-03-10 1. 방법 우선 아래의 라이브러리들의 import가 필요하다. import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.io.StringReader; 이후 처리해야 할 xml 형태의 String 변수를 해당 라이브러리들을 사용하여 원하는 값을 추출할..