String[] attributes = pickTwo("좋은", "빠른", "저렴한"); 제가 자바 기초가 약해서 이해를 못하는걸까요? .. bytecode로 확인하면 pickTwo 메소드를 반환하게 된다면 Object(추상적) 형식으로 반환 해서 String(구체적) 형식으로 변환(타입 케스트) 해서 문제(ClasscastException)가 발생된다고 해주셨는데요 그러니깐 구체적 -> 추상적 으로 변환 문제없음 추상적 -> 구체적 으로 변환 문제 있음 결론은 이것인데 Object obj = new Object(); obj = "test"; // 추상적인 Object 에 담음 String string = (String) obj; // 구체적인 String 에 담음 해당 원인이라면 해당 소스는 에러가 발생해야 되는것이 아닌가요?.... 자바 기초가 약해서 그런지 조금 이해가 안되는 부분이 있어서 질문 드립니다.
#include <stdio.h> int main() { //배열의 이름은 배열의 첫번째 인덱스 주소 int arr1[] = { 101, 102, 103 }; int arr2[] = { 104, 105, 106 }; printf("%p, %p, %p\n", &arr1, arr1, &arr1[0]); int arr3[2][3] = { {1,2,3},{4,5,6} }; printf("%p, %p, %p\n\n", &arr3, arr3, &arr3[0]); //포인터의 이름은 할당된 주소 //&포인터는 포인터도 변수니까 그에 대한 주소(자료형에 관계 없이 메모리 주소 사이즈) int* prt = arr1; printf("%p, %p, %p\n", &prt, prt, arr1); int* parr[2] = {arr1[0],arr2[1]}; printf("%p, %p, %p\n", &parr, parr, arr1); return 0; } 안녕하세요. 10.14 강의 내용 질문은 아니지만 이 강의부터 진도를 못나가고 있어요 ㅠ '이름'에 대한 강조가 많아 혼란스러워 질문 드립니다. 1. &배열이름($arr1)에서 배열 이름이 주소인데 앞에 &을 붙여 사용하는 경우도 있나요? 사용할 경우 그냥 arr1과 같은 주소 나오는 건가요? 2. 포인터에서 &prt와 prt 차이는 포인터도 변수니까 그에 대한 주소와 포인터에 할당된 주소 차이로 봐도 될까요? 3. 그런데 포인터[] 배열에서는 &parr, parr의 주소 같게 나오는데 이유가 궁금합니다. 이 주소는 변수 주소인가요? 늘 감사합니다.
안녕하세요, Spring Cloud Gateway 프로젝트 생성 파트 진행 도중 http://127.0.0.1:8081/first-service/welcome 에 접속시 아래와 같은 현상으로 접속이 되지 않습니다. ecommerce 서버, apigateway서버, first-service 서버를 구동했음에도 제대로 접속되지 않는 이유가 무엇일까요? 감사합니다.
안녕하세요 개복치 강사님! 강의 열심히 듣고있습니다. 현재 강의 따라가며 비회원 로그인 파트 공부중인데요, 파이어베이스와 관련된 코드들이 제대로 작동하지 않아 살펴보니 에뮬레이터의 wifi 가 no internet으로 되어있는 것이 문제임을 확인했습니다. //게스트 로그인 버튼 guestLoginBtn.setOnClickListener { auth.signInAnonymously().addOnCompleteListener(this) { task -> if (task.isSuccessful) { val user = auth.currentUser Log.d("LoginActivity", user!!.uid) } else { // If sign in fails, display a message to the user. Toast.makeText(baseContext, "Authentication failed.", Toast.LENGTH_SHORT).show() } } 위 코드를 실행하면 일정 시간 후에 "Authentication failed" 토스트 메세지를 띄웁니다. 지금까지 아래 링크에서 설명하는 방법들과 https://medium.com/@daydreamer_/how-to-fix-android-emulator-wi-fi-connected-with-no-internet-c62fd4ed652d https://www.imobie.com/android-system-recovery/android-wifi-connected-but-no-internet.htm API level이 29 아래인 에뮬레이터를 새로 생성해서 사용해보고 AVD를 Cold boot 해보는 방법을 시도해봤지만 문제가 해결되지 않고 있습니다. 안드로이드 스튜디오는 돌핀버전 사용중입니다. 오랜시간 구글링해봤지만 제가 문제를 잘못 접근하고있는건지.. 답답하네요. 강사님 도움이 절실합니다..ㅜㅜ
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. http://boj.kr/3dcbdac3a6c248f7af9feda6f9620739 안녕하세요 강사님, 질문 게시판에 있는 반례와 백준 질문검색에 있는 반례를 전부 다 해봐도 정답으로 나오는데 계속 틀렸다고 뜹니다...너무 답답하네요 이유를 알 수 있을까요?? 감사합니다.
public static void main(String[] args) { Main main = new Main(); Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); int[][] answers = new int[num][num]; for (int row = 0; row < num; row++) { for (int col = 0; col < num; col++) { answers[row][col] = scanner.nextInt(); } } System.out.println(solution(answers)); } private static int solution(int[][] nums) { int size = nums.length; int[] colSum = new int[size]; int[] rowSum = new int[size]; int leftDiagonalSum = 0; int rightDiagonalSum = 0; for (int row = 0; row < size; row++) { for (int col = 0; col < size; col++) { rowSum[row] += nums[row][col]; colSum[col] += nums[row][col]; if (row == col) { leftDiagonalSum += nums[row][col]; } if (row + col == 4) { rightDiagonalSum += nums[row][col]; } } } int colMax = Arrays.stream(colSum).max().getAsInt(); int rowMax = Arrays.stream(rowSum).max().getAsInt(); return Stream.of(colMax, rowMax, rightDiagonalSum, leftDiagonalSum) .max(Comparator.comparing(Integer::intValue)) .get(); } } 전체를 돌면서 row, col 의 좌표값으로 대각선값을 구하게 했는데요. 선생님 강의를 보면 더 단순하게 생각할 수 있다고 느낍니다. 단순 코드차이로 보면 될까요? 아니면 제가 앞으로 문제를 풀면서 더 단순하게 생각해야할까요?
먼저 좋은 강의 감사드립니다. 프로세스 = 실행 중인 프로그램 (혹은 어플리케이션) 이라고 이해했는데요. 실무에서 서버 N대를 사용한다고 할 때, 이는 프로세스의 개수와도 같은 말일까요? EX) Synchronized 는 하나의 프로세스 안에서 보장된다 -> 서버가 n대일 때는 프로세스도 n개 이다. 단일 서버 환경은 프로세스가 여러개 일 수 없는 건지, 서버와 프로세스의 개념이 헷갈려서 여쭙습니다.
예외처리에 관해서 공부하고 있는 취준생입니다. 공부 중 막히는 부분이 있어 질문을 하고자 합니다. 우선 제 코드를 보여드리겠습니다. 코드는 이곳 에서 참고해서 따라하고 있습니다. Custom 예외를 만들 ErrorCode 클래스 @Getter @AllArgsConstructor public enum ApiErrorCode { // 400번대 에러: 클라이언트에서의 잘못된 요청 MEMBER_NOT_FOUND(NOT_FOUND, "멤버를 찾을 수 없습니다."), // 500번대 에러: 서버 내부에서의 에러 발생 SYSTEM_ERROR(INTERNAL_SERVER_ERROR, "시스템 내부 오류입니다."); private final HttpStatus httpStatus; private final String detail; } 예외 응답하는 클래스 @Getter @Builder public class ApiErrorResponse { private final int status; private final String error; private final String errorCode; private final String errorMessage; public static ResponseEntity<ApiErrorResponse> toResponseEntity(ApiErrorCode apiErrorCode) { return ResponseEntity .status(apiErrorCode.getHttpStatus()) .body( ApiErrorResponse.builder() .status(apiErrorCode.getHttpStatus().value()) .error(apiErrorCode.getHttpStatus().name()) .errorCode(apiErrorCode.name()) .errorMessage(apiErrorCode.getDetail()) .build() ); } } 예외를 발생시킬 클래스 @Getter @AllArgsConstructor public class ApiException extends RuntimeException { private final ApiErrorCode apiErrorCode; } @RestControllerAdvice @RestControllerAdvice public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { @ExceptionHandler(value = {ApiException.class}) protected ResponseEntity<ApiErrorResponse> handleApiException(ApiException e) { return ApiErrorResponse.toResponseEntity(e.getApiErrorCode()); } } @Service @Service @RequiredArgsConstructor public class MemberService { private final MemberRepository memberRepository; BasicResponse basicResponse = new BasicResponse(); // Member 하나 조회 public BasicResponse findMember(Long memberId) { Optional<Member> member = memberRepository.findById(memberId); if (member.isPresent()) { basicResponse = BasicResponse.builder() .code(HttpStatus.OK.value()) .httpStatus(HttpStatus.OK) .message("Member 조회에 성공하였습니다.") .result(Arrays.asList(member.get())) .build(); } else { throw new ApiException(ApiErrorCode.MEMBER_NOT_FOUND); } return basicResponse; } 포스트맨으로 예외 발생시켰을 때 결과 화면 제가 궁금한 것은 예외가 발생했을 때 Response에 넣어주는 객체에 현재 어떤 요청 url에 대하여 예외가 발생했는지를 알려주기 위해 path를 넣고 싶은데 이것을 어떻게 하면 좋을지입니다. 도움 주시면 감사하겠습니다.
안녕하세요 dp 문제 풀다가 질문 생겨서 글 올립니다. dp 문제 해설해주신 것을 보면 보통 int &ret = dp[here][visited]; 위와 같이 참조 연산자를 통해 해결하셨는데 특별한 이유가 있으신가요? 아래와 같이 dp[here][visited]를 그대로 사용하여도 답은 맞는데 틀릴 수 있는 요소가 있는건가요? http://boj.kr/8eb4583e29264375bf3a98f2ec846063