전체 글
-
[TIL] (230623) MySQl 기존에 설정된 포트 삭제하기(오류 해결) / ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)TIL 2023. 6. 23. 14:04
오늘은 Spring을 사용하기 위해 환경변수 설정, 테스트 코드 실행, Lombook의 사용이유, MySQL설치를 진행했다. 인텔리제이로 Spring의 기본코드를 구현하고 Postman으로 GET 연습을 해봤다. 🔸문제점 MySQL을 설치하고 [MySQL 8.0 Command Line Client]로 접속하여 데이터베이스 생성 및 이동(정상) 환경변수 설정 후 cmd로 MySQL에 접속하는데 이런 오류메시지가 떴다. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 🔸시도해 본 것 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using p..
-
[자바(JAVA)] 완주하지 못한 선수 /Arrays.sort(), equals(),HashMap, getOrDefault()카테고리 없음 2023. 6. 20. 14:26
https://school.programmers.co.kr/learn/courses/30/lessons/42576 ✅ 내 풀이 import java.util.Arrays; class Solution { public String solution(String[] participant, String[] completion) { String answer = ""; Arrays.sort(participant); Arrays.sort(completion); for(int i=0;i 2) i = 2이고 i++진행( 2 -> 3) return participant[3]; ✅ 다른풀이 (2) import java.util.HashMap; class Solution { public String solution(String..
-
[자바(JAVA)] 나누어 떨어지는 숫자 배열 / Arrays.copyOf(), sort(), ArrayList<>, Collections.sort()프로그래머스/자바(JAVA) 2023. 6. 19. 16:52
✅ 내 풀이 ① import java.util.Arrays; class Solution { public int[] solution(int[] arr, int divisor) { int[] answer = new int[arr.length]; int index = 0; // 새 배열의 인덱스값 확인하기 for(int i : arr){ if(i % divisor == 0) { answer[index] = i; index++; } } if(index == 0) { return new int[] {-1}; }else { answer = Arrays.copyOf(answer, index); // 초기화된 값 잘라내기 Arrays.sort(answer); return answer; } } } 처음에는 주어진 배열인..
-
[WIL] (230618_ 3주차) JVM과 객체지향 프로그래밍이 무엇인지 알아보았다.WIL 2023. 6. 18. 21:08
🔹 배운 내용 정리 이번주에는 자바 가상머신(JVM)과 객체지향 프로그래밍이 무엇인지 배우는것에 대해 집중했다. 내가 배우고 이해한 대로 정리하자면 1. JVM 란 - 클래스 로더(Class Loader) - 실행 엔진(Execution Engine) - 런타임 데이터 영역(Runtime Data Area) 등을 사용하여 다양한 운영체제에서 작동될 수 있도록 해주는 가상 머신이다. 일반 애플리케이션의 코드는 OS와 바로 맞붙어 있어서 OS에 종속적이나, Java의 경우 JVM을 거치면서 여러 OS에서 실행 가능한게 장점이었다! "자바의 정석"에서 알려준 JVM의 메모리 구조인데 코드를 실행하면 어디에 어떤 작업이 쌓이게 되는지 직접 그려가며 확인을 하니까 훨씬 이해가 쉬워서 좋았다. 2. 객체지향 프로그..
-
[TIL] (230617) 중복값이 존재할 수 있는 두 배열을 비교하여 포함되지 않은 요소를 찾아내자.-> 소거법 or HashMap 이용하기.TIL 2023. 6. 17. 14:57
오늘도 조건문과 반복문을 활용한 프로그래머스 문제를 풀어보았다. 이제는 단순히 조건문, 반복문의 사용법뿐만 아니라 늘 사용하던 형태들( int [], String [], ArrayList )이 아닌 다양한 변수들의 형태와 특징을 알아보고 적재적소에 활용하는 문제풀이가 필요했다. 🔸문제 발생 문제링크: https://school.programmers.co.kr/learn/courses/30/lessons/42576 - 조건 String[] participant: 마라톤 경기에 참여한 모든 선수들의 이름이 담긴 배열 String [] completion: 완주한 모든 선수들의 이름이 담긴 배열 완주하지 못한 선수의 이름을 return 하는 함수를 작성해라 * 1≤ 참여한 선수의 수 ≤ 100,000명 * c..
-
[자바(JAVA)] 서울에서 김서방 찾기(equals(), Arrays.asList().indexOf() ), 향상된 for문프로그래머스/자바(JAVA) 2023. 6. 17. 10:37
✅ 내 풀이 class Solution { public String solution(String[] seoul) { String answer = ""; String find = "Kim"; for(int i=0; i 리스트 기본형 배열의 경우 각 요소는 해당 기본형의 래퍼 클래스로 자동 변환된다. 예시) 2. indexOf("Kim") indexOf() 컬렉션 또는 문자열에서 특정 요소 또는 문자열이 처음으로 등장하는 인덱스를 반환하는 메서드이다. 이 메서드는 주어진 요소 또는 문자열을 찾아서 해당 위치의 인덱스를 반환하며, 찾지 못한 경우 -1을 반환한다. 배열에서 특정 문자열이 처음으로 나오는 인텍스를 찾는건 indexOf()만 있으며, 배열형의 경우 List인터체이스를 구현한 컬렉션 클래스에서만 사..
-
[자바(JAVA)] 문자열 다루기 기본 (삼항연산자, matches, 정규식)카테고리 없음 2023. 6. 17. 09:56
✅ 내 풀이 class Solution { public boolean solution(String s) { return ((s.length() == 4 || s.length()==6) && s.matches("[0-9]+")); } } 1. 길이판별 2. 문자열에 0~9까지만 있는지 판별(matches) 💬matches() 문자열이 정규식과 일치하는지 여부를 확인하는 데 사용되는 메서드입니다. 정규식은 특정한 패턴을 표현하는 문자열 패턴입니다. matches() 메서드는 주어진 문자열이 정규식과 완전히 일치하는지를 검사합니다. 즉, 주어진 문자열 전체가 정규식과 일치해야 true 를 반환하고, 그렇지 않으면 false 를 반환합니다. 🔽 정규식이 아닌 조사방법 // 문자열을 하나씩 순회하며 검사하는 방법..
-
[자바(JAVA)] 문자열 내 p와 y의 개수 (toLowerCase)프로그래머스/자바(JAVA) 2023. 6. 17. 09:14
✅ 내 풀이 class Solution { boolean solution(String s) { String lowercase = s.toLowerCase(); int p = 0, y = 0; for(int i=0; i 'Y'== e).count(); } } stream은 아직 배우지 않았으나 코드가 간결해보여서 어떤 의미인지 찾아봤다. s = s.toUpperCase();: 주어진 문자열 s를 대문자로 변환합니다. 이는 문자열의 모든 문자를 대문자로 통일시킵니다. 이 작업은 두 번째 줄에서 사용되는 s.chars() 메서드를 통해 문자열을 문자 스트림으로 변환하기 전에 수행됩니다. s.chars().filter( e -> 'P'== e): 문자열 s를 문자 스트림으로 변환한 후, 해당 스트림에서 문자 '..