2025/02/20 6

[Java] 접근제어자

1. 클래스의 접근제어자클래스를 정의할 때 사용할 수 있는 접근제어자 : public & defaultpublic : 모든 클래스에서 접근이 가능하다.default(생략) : 같은 패키지 안의 클래스에서만 접근이 가능하다.public class Book { // public 클래스 ...}class NoteBook { // default 클래스 ...} 2. 클래스 멤버의 접근 제어자클래스 멤버를 정의할 때 사용할 수 있는 접근제어자 : public, private, protected, default(생략)public : 공개 , 모든 클래스에서 접근이 가능private : 비공개 , 같은 클래스 안에 있는 멤버들만 접근이 가능protected : 같은 패키지 안의 모든..

Java 2025.02.20

[MongoDB] 설치 에러 : mongo 커맨드 없음 에러

0. 들어가기 전에만약 환경 변수 설정을 아직 안하셨다면 환경변수 설정을 완료해주세요.cmd 창에서 아래의 명령어는 잘 나오는 상태여야 합니다.   1. 에러 원인MongoDB 6.0 버젼부터 mongo 명령어 대신 mongosh를 사용한다는 공식문서가 있습니다.그래 mongoshell을 설치해주어야 합니다. 2. 해결 방법https://www.mongodb.com/try/download/shell?jmp=docs위 링크에 들어가 mongodb shell msi 다운로드해주세요. 이후 cmd 창에 들어가서 명령어를 치면 해결가능합니다.

Database/MongoDB 2025.02.20

[프로그래머스] 나누어 떨어지는 숫자 배열

1. 내 풀이string builder를 배우고 활용해보았는데, 이 방법보다는 list를 이용해 푸는게 더 효율적이었을 것 같다. 왜이렇게 풀었지 ..import java.util.*;class Solution { public int[] solution(int[] arr, int divisor) { int[] answer = new int[1]; StringBuilder sb = new StringBuilder(); for(int num : arr ) { if(num % divisor == 0) sb.append(num+" "); } if(sb.length() == 0) { answer[0] = -..

[프로그래머스] 정수 제곱근 판별

1. 내 풀이String 으로 바꿨다가 Long으로 바꿨다가 살짝 온몸비틀기해서 풀었다. class Solution { public Long solution(long n) { long answer = 0; double num = Math.sqrt(n); if(num - (int)num > 0) return -1L; String s = ((int)Math.sqrt(n) + 1) + ""; Long num3 = Long.parseLong(s); return num3 * num3; }}  2. 다른분 풀이Math.pow와 Math.sqrt를 이용하여 간단히 구할 수 있었다.class Solution { pub..

String Builder 내장함수 알아보기

1. appendStringBuilder 객체에 값을 넣을 수 있다. 어떤 자료형이든 string과 비슷한 형태로 저장되게 된다.append(boolean b)append(char c)append(char[] str)append(char[] str, int offset, int len)append(double d)append(float f)append(int i)append(long lng)append(CharSequence s)append(CharSequence s, int start, int end)append(Object obj)append(String str)append(StringBuffer sb)appendCodePoint(int codePoint)2. deleteStringBuilder 객체..

Java 2025.02.20