우선, 메서드와 생성자의 정확한 차이부터 짚고 가야한다. 메서드와 생성자 차이구분 메서드 (Method) 생성자 (Constructor) 목적객체가 가진 동작/기능을 정의객체가 생성될 때 초기화이름아무 이름 가능클래스 이름과 동일해야 함반환 타입있어야 함 (void, int, etc)❌ 없음 (void도 안 씀)호출 시점객체가 만들어진 후 호출new 클래스명() 할 때 자동 호출호출 방법객체.메서드()new 클래스()상속/오버라이딩메서드는 오버라이드 가능생성자는 상속/오버라이드 불가 (다만 super()로 호출 가능) 업캐스팅과 다운캐스팅 개념방향설명업캐스팅자식 → 부모자식 객체를 부모 타입으로 참조 (자동)다운캐스팅부모 → 자식부모 타입 참조를 자식 타입으로 형변환 (명시적) 단, 실..

처음 작성한 코드 - 1차원 배열import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] s = new String[8]; int cnt = 0; for (int i = 0; i 코드가 너무 중복되는 것 같아 조금 바꿔본다. 처음 작성한 코드 간결화import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); ..

기존 작성 코드import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double a = sc.nextDouble(); double b = sc.nextDouble(); System.out.println(a/b); }} 예제 테스트입력1 3출력0.3333333333333333 정답 값은 소수점 아래 32개의 숫자가 나오지만, double형의 값 범위 때문에 16자리까지밖에 표현되지 않았다. 변경 코드import java.math.B..

import java.io.IOException;import java.util.Scanner;public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); String str = sc.next(); StringBuffer sb = new StringBuffer(str); String reversedStr = sb.reverse().toString(); if(str.equals(reversedStr)) { System.out.println(1); } else { S..

기존에 작성한 코드import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int[] n = new int[t]; for (int i = 0; i 결과는 런타임 에러.. 이것저것 시도해보다 보니 int형보다 큰 숫자가 들어가서 그렇다고 한다. 새로 작성한 코드import java.math.BigInteger;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = ne..

EOF 정의EOF는 "End of File"의 약자로, 파일이나 데이터 스트림의 끝을 나타내는 특별한 마커입니다. 프로그래밍에서 EOF는 입력이 더 이상 없음을 의미합니다. 브론즈3 문제임에도 정답률이 34.6%로 현저히 낮은 문제이다.. 처음에는 split를 사용해서 개행(\n)으로 구분해봤는데 잘 되지 않음 좀 더 해보다가 결국 알아본 해결책 import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNextLine()) { String str = sc.nextLine(); System.out..

두 문제는 푸는 과정이 비슷하여 같이 작성한다. 두 문제 모두 세 자리 수의 각각 백의 자리, 십의 자리, 일의 자리 숫자를 구해야 한다. [2588 곱셈] public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 0; int a = 0; n = sc.nextInt(); a = sc.nextInt(); int b = a / 100;//100의 자리 int c = a % 100 / 10;//10의 자리 int d = a % 10;//1의 자리 System.out.println(n*d); System.out.println(n*c); System.out.println(n*b); ..

첫 번째 정수 a는 b보다 작아야 한다. a가 1이라면 그냥 a와 b를 곱하면 된다. b가 a로 나누어 떨어진다면 그냥 b가 최소공배수이다. 그것이 아니라면, 작업을 수행해야 한다. d를 for문의 i처럼 활용하였다. 정수 b에 d를 곱해보면서, a와 나누어 떨어지는 수를 찾는 것이다. for문 보다는 while문을 사용하기에 적절하다. 무한루프 while문에서 최소공배수 c를 찾으면 탈출하게 된다. public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = 0;//첫 번째 정수 long b = 0;//두 번째 정수 long c = 0;//최소공배수 int d = 2;//i ..

나머지를 저장하는 일 까지는 수월히 했다가... 서로 다른 값의 수를 구하라 했을 때 읭..? 했다. 고민하다가 저번에 배운 중복을 허용하지 않는 HashSet이 생각나서 응용해 보기로 했다. import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] a = new int[10]; Set nSet = new HashSet(); for (int i = 0; i < a.length; i++) { a[i] = sc.nextInt(); nSet.add(a[..

처음 짠 코드는 시간복잡도가 O(n * m) 이라 시간 초과 당했다... 아래가 처음 코드 public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 0, m = 0; int a = 0; n = sc.nextInt(); int[] nArr = new int [n]; for (int i = 0; i < nArr.length; i++) { nArr[i] = sc.nextInt(); } m = sc.nextInt(); int[] mArr = new int [m]; for (int i = 0; i < mArr.length; i++) { mArr[i] = sc.nextInt(); } ..
- Total
- Today
- Yesterday
- docker
- docker컨테이너
- 알고리즘
- 오블완
- 톰캣
- 백준자바
- 노드
- 백준
- tomcat
- db
- 자바
- BigDecimal
- docker앱배포
- 웹스퀘어
- google cloud run
- 클라우드
- websquare
- 그리드
- Spring
- Apache
- 이클립스
- dockerspring
- controller
- 티스토리챌린지
- 트리
- MySQL
- Java
- SpringBoot
- docker배포
- 백준알고리즘
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |