이미지와 같이 Runtime Error 발생하여, 검토 요청드립니다. import java.util.*; public class Main { private int solution (int i1, int[][] i2) { int r = 0; int rt = 0; for (int i = 0; i < i1; i++) { int t = 0; boolean[] s = new boolean[i1]; for (int j = 0; j < 5; j++) { for (int k = 0; k < i1; k++) { if (i2[i][j] == i2[k][j]) { s[k] = true; } } } for (boolean a: s) { if (a) { t++; } } if (t > rt) { r = i; rt = t; } } return r + 1; } public static void main(String[] args){ Scanner in = new Scanner(System.in); int input1 = in.nextInt(); int [][] input2 = new int[input1][input1]; for (int i = 0; i < input1; i++) { for (int j = 0; j < 5; j++) { input2[i][j] = in.nextInt(); } } System.out.println(new Main().solution(input1, input2)); } }
DataInitializer 와 관련하여, EntityManager 를 @Autowired 가 아닌, @PersistenceContent 로 가져온 까닭이 궁금합니다. 제가 이해한 바에 따르면, initialize 메서드에서 정의된 ExecutorService 의 스레드 풀은 트랜잭션 전파가 이뤄지지 않으니, TransactionTemplate 을 사용하여 명시적으로 트랜잭션 블록을 지정해주고, 영속화를 위한 과정에서, entityManager 의 프록시 객체가 트랜잭션 내부에서 적절한 객체를 가져와 수행한다고 알고 있습니다. 이 과정에서, EntityManager 의 프록시 객체를 위해 @PersistenceContext 를 사용하여 선언함은 알겠으나, @Autowired 를 사용하여 스프링에서 관리하는 것 역시도 SharedEntityManager 에서 파생된, 동일한 프록시 객체를 반환하는 걸로 알고 있습니다. PersistenceContext 로 em 을 가져온 이유가 있나요? 아니면 선호하시는 방식이라 채택한 방법인가요? 물론 제가 이해한 바에서 틀린 부분이 있을 수도 있으니 잘못 이해한 바가 있으면 정정도 부탁드립니다. 강의 잘 보고 있습니다~
p.18. 다운스트림 컬렉터부분에 1.groupBy(Student::grade) 가 아니고 1.groupingBy(Student::getGrade) 로 바뀌어야 되는거 아닌지요. 오타인거 같습니다. record로 선언된 클래스가 아니어서요. p. 23 reducing 그림에서도 비슷한 오타가 보입니다.
자식 생성자 생성되고 child() 왔다가 부모 올라가서 parent() 먼저 출력후 자식내려와서 super() 이니까 또 parent() 출력하고 다시 내려와서 child constructor 해야하지 않나요? parent constructor parent constructor child constructor 라고 생각했는데 아닌 이유가 뭘까요..
30강 9:44에서 부모 자식 기본 생성자가 출력되지 않았는데 그 이유가 super에 파라미터가 있어서 그 값을 출력했다 라고 이해했는데 만약super()이런식으로 파라미터의 값을 설정하지 않았다면 부모 자식 기본 생성자가 호출 되는 건가요? Car() 이런 식으로요 10:26에서는 왜 부모 기본 생성자는 출력하는데 자식의 기본 생성자인 ECar()은 출력 하지 않나요? 부모자식 다 출력하는게 아니라 조건이 없을때 부모만 출력하는건가요?
문자열이 비어있는지 판단하는것이 string str = "Hello"; 가 있냐 없냐로 판단하는 것인가요??? 설명란에 Hello라는 문자열이 변수에 들어가 있고 그것이 비었는 지를 물어보는 기능이 참값이 나온다는데 비어있으면 참값이고 그렇지 않으면 거짓값인데 답이 거짓값이 나와서 이해가 조금 부족합니다..ㅠㅠ
시간대는 9분 25초이구요, 기본 생성자를 거치지 않고 ElectricCar(String model, int year, int batteryCapacity) { super(model, year); this.batteryCapacity = batteryCapacity; System.out.println("ECar(" + batteryCapacity + ")"); } } 해당 코드에서 super(model, year); 을 타고 Car(String model, int year) { this.model = model; this.year = year; System.out.println("Car(" + model + ", " + year + ")"); } } 해당 코드가 실행되어 println 되고, 다음 자식 생성자가 실행되어서 ECar(75) 의 값이 나오는 걸로 보여지는데 Q. new electricCar에서 기본 생성자를 거치지않고 어째서 2번째 자식 생성자로 바로 가버려서 코딩이 되지요?? 이게 명시적 호출인가요?
안녕하세요 쿠케님 강의 잘 보고 있습니다! 강의를 보다가 갑자기 궁금한 점이 생겨서 질문 드립니다. 샤딩의 기준이 현재는 article_id로 되어 있는데, 특정 샤드에 댓글 데이터가 엄청 생성되어서 불균형하게 저장이 되는 경우도 있을까요?? 있다면 샤딩의 기준을 다시 정의하는 일도 있는지 궁금합니다. 항상 잘 보고 있습니다. 감사합니다.
이전까지 업캐스팅에서 부모의 기본생성자를 먼저 출력하고 다음에 자식의 생성자를 실행한다고 배웠는데 여기선 빼고 바로 B의 생성자로 가는 이유가 무엇인가요 앞 문제와 파라미터가 들어간 메인함수는 똑같은데 오버로딩과 무슨 관련이 있나요 B의 기본생성자에서 명시적으로 파라미터가 들어간 부모 생성자를 호출하기에 부모 기본생성자를 생략해도 되는건가요
29:27 삼항 연산자 한 줄로 되어있는 부분 해석해주실 때, if level % 2 != 0: 위 부분이 이해가 안됩니다. if node else 0 이 부분은 "if 부분이 참이면 return을 하고"라고 해석을 해주셨는데요 왜 if level % 2 != 0: 이 부분 해석해주실 때에는 != 같지 않다라고 해석을 해주시는지 궁금합니다.
안녕하세요! 강의 잘 듣고 있습니다. 좋은 강의 감사합니다. 실습하다가 오류가 생겨 문의 드립니다. void like(Long articleId, Long userId, String lockType) { restClient.post() .uri("/v1/article-likes/articles/{articleId}/users/{userId}/" + lockType, articleId, userId) .retrieve(); } @Test void likePerformanceTest() throws InterruptedException { ExecutorService executorService = Executors.newFixedThreadPool(100); // 100개의 스레드 풀 생성 // 각 lock type별로 테스트 likePerformanceTest(executorService, 1111L, "pessimistic-lock-1"); likePerformanceTest(executorService, 2222L, "pessimistic-lock-2"); likePerformanceTest(executorService, 3333L, "optimistic-lock"); } void likePerformanceTest(ExecutorService executorService, Long articleId, String lockType) throws InterruptedException { CountDownLatch latch = new CountDownLatch(3000); System.out.println(lockType = " start"); like(articleId, 1L, lockType); long start = System.nanoTime(); for (int i = 0; i < 3000; i++) { long userId = i + 2; // String finalLockType = lockType; executorService.submit(() -> { like(articleId, userId, lockType); latch.countDown(); }); } latch.await(); long end = System.nanoTime(); System.out.println("lockType = " + lockType + ", time = " + (end - start) / 1_000_000 + " ms"); System.out.println(lockType + " end"); Long count = restClient.get() .uri("/v1/article-likes/articles/{articleId}/count", articleId) .retrieve() .body(Long.class); System.out.println("count = " + count); } 여기서 '람다 식에 사용되는 변수는 final 또는 유사 final이어야 합니다' 라는 오류가 뜨더라고요. // String finalLockType = lockType; 부분 주석 해제하고 람다 내부에 like(articleId, userId, finalLockType); 으로 하면 start lockType = start, time = 914 ms start end count = 0 start lockType = start, time = 589 ms start end count = 0 start lockType = start, time = 567 ms start end count = 0 으로 출력도 잘 안 나옵니다. 애플리케이션 콘솔에는 아래 로고만 찍히고 나머지는 안 나옵니다. Hibernate: select alc1_0.article_id,alc1_ 0.like _count,alc1_0.version from article_like_count alc1_0 where alc1_0.article_id=? Hibernate: select alc1_0.article_id,alc1_ 0.like _count,alc1_0.version from article_like_count alc1_0 where alc1_0.article_id=? Hibernate: select alc1_0.article_id,alc1_ 0.like _count,alc1_0.version from article_like_count alc1_0 where alc1_0.article_id=? 어느 부분이 문제일까요? ArticleLikeController에서 count 경로는 테스트처럼 뒤에 /count 추가했습니다.