Banner

My Tech Blog (๋ฉ”์„œ๋“œ)

์˜ค๋Š˜์˜ ๋ช…์–ธ
๐Ÿ“‘ 1. ์ตœ๋Œ“๊ฐ’ ๋งŒ๋“ค๊ธฐ ๐Ÿ’ก ํ’€์ด๊ณผ์ •๋ฐฐ์—ด์„ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ ๋’ค์— ๊ฐ€์žฅ ๋ ๊ฐ’ 2๊ฐœ๋ฅผ ๊ณฑํ•œ ๊ฐ’, ์‹œ์ž‘๊ฐ’ 2๊ฐœ๋ฅผ ๊ณฑํ•œ ๊ฐ’ ์ค‘ ๋” ํฐ ๊ฐ’์„ ๋ฐ˜ํ™˜์ด๋ ‡๊ฒŒ ํ•˜๋Š” ์ด์œ ๋Š” ์š”์†Œ๊ฐ€ ์–‘์ˆ˜์ผ ์ˆ˜๋„ ์žˆ๊ณ  ์Œ์ˆ˜์ผ ์ˆ˜๋„ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.  ๐Ÿ‘จโ€๐Ÿ’ป ์ •๋‹ต์ฝ”๋“œimport java.util.*;class Solution { public int solution(int[] numbers) { Arrays.sort(numbers); int n = numbers.length; // ๊ฐ€์žฅ ํฐ ๋‘ ์ˆ˜์˜ ๊ณฑ vs ๊ฐ€์žฅ ์ž‘์€ ๋‘ ์ˆ˜์˜ ๊ณฑ ์ค‘ ์ตœ๋Œ“๊ฐ’ ๋ฐ˜ํ™˜ // ์Œ์ˆ˜์ผ ๊ฐ€๋Šฅ์„ฑ ๋•Œ๋ฌธ์ž„ return Math.max(numbers[n - 1] * numbers[n - 2..
Spring ํ”„๋กœ์ ํŠธ์—์„œ๋Š” ์„œ๋น„์Šค ๋ ˆ์ด์–ด์—์„œ ์ธํ„ฐํŽ˜์ด์Šค(*Mgr.java)์™€ ๊ตฌํ˜„ ํด๋ž˜์Šค(*MgrImpl.java)๊ฐ€ ๋ถ„๋ฆฌ๋˜์–ด ์žˆ์–ด, F3(Open Declaration)๋ฅผ ๋ˆŒ๋Ÿฌ๋„ ์ธํ„ฐํŽ˜์ด์Šค๋กœ๋งŒ ์ด๋™ํ•˜๋Š” ๋ถˆํŽธํ•จ์ด ์žˆ๋‹ค. ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด Open Implementation ๊ธฐ๋Šฅ์„ ํ‚ค๋ณด๋“œ ๋‹จ์ถ•ํ‚ค(Ctrl + F3)๋กœ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ •๋ฆฌ ํ•ด ๋ณธ๋‹ค. ๐Ÿ”น ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•: Open Implementation ๋‹จ์ถ•ํ‚ค ์„ค์ •ํ•˜๊ธฐ 1. Eclipse ํ™˜๊ฒฝ์„ค์ • Window โ†’ Preferences (๋˜๋Š” Alt + W, P)2. ์ขŒ์ธก ๋ฉ”๋‰ด์—์„œ General โ†’ Keys ์„ ํƒ3. "Open Implementation" ๋‹จ์ถ•ํ‚ค ์ง€์ • type filter text์— Open Implementation ์ž…๋ ฅ Binding(๋‹จ์ถ•..
๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช… ๐Ÿ’ก 2. ์˜ค๋‹ต์ •๋ฆฌ (ํ‹€๋ฆฐ์ฝ”๋“œ)class Solution { public String solution(String my_string, String letter) { StringBuilder sb = new StringBuilder(); for(char c : my_string.toCharArray()) { if(!c.equals(letter) sb.append(c); } return sb.toString(); }} string ํƒ€์ž…๋ผ๋ฆฌ ๋น„๊ตํ•  ๋•Œ๋Š” .equals ๋ฅผ ์“ด๋‹ค. ๊ทธ๋ž˜์„œ .equals์˜ ๋ถ€์ •์ธ !c.equals(letter)์„ ์ผ๋Š”๋ฐ ์ด ๋ถ€๋ถ„์ด ํ‹€๋ ธ๋‹ค. ํ‹€๋ฆฐ ์ด์œ ๋Š” String ์ด๋ž‘ char ํƒ€์ž…..
๐Ÿ“‘ 1. ๋ฌธ์ž์—ด ์„ž๊ธฐ ๐Ÿ’ก 1-1. ์ ‘๊ทผ๋ฐฉ์‹โ–  ๋‹จ์ˆœํžˆ ์ฃผ์–ด์ง„ ๋ณ€์ˆ˜๋ช… ๊ทธ๋Œ€๋กœ a + b > b + a ์ด๋ ‡๊ฒŒ ๋น„๊ตํ•˜๋ฉด ๋‘ ์ˆซ์ž๋Š” ์ •์ˆ˜ ๋ง์…ˆ์ด๊ธฐ ๋•Œ๋ฌธ์— ํ•ญ์ƒ a + b == b + a๊ฐ€ ๋œ๋‹ค. ๋ฌธ์ œ์—์„œ ์˜๋„ํ•œ ๊ฒƒ์€ ์ˆซ์ž๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ์—ฐ๊ฒฐํ•œ ํ›„, ํฌ๊ธฐ๋ฅผ ๋น„๊ตํ•˜๋Š” ๊ฒƒ์ด๋‹ค. ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋น„๊ตํ•˜๋ ค๋ฉด String.valueOf(a) + b์™€ String.valueOf(b) + a ๋ฅผ ๋น„๊ตํ•ด์•ผ ํ•œ๋‹ค.  โ–   ๋˜ ๋‚˜๋Š” ์ฒ˜์Œ์— sb.toString()์„ ์จ์„œ int๋กœ ๋ฐ˜ํ™˜ํ•˜๋Š” ์‹ค์ˆ˜๋ฅผ ํ–ˆ๋Š”๋ฐ,  sb.toString()์€ ๋ฌธ์ž์—ด์ด๊ธฐ ๋•Œ๋ฌธ์—, int ํƒ€์ž…์„ ๋ฐ˜ํ™˜ํ•˜๋Š” solution ๋ฉ”์„œ๋“œ์™€ ํƒ€์ž…์ด ๋งž์ง€ ์•Š๋Š”๋‹ค. ๊ทธ๋ž˜์„œ Integer.parseInt(sb.toString())์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ณ€ํ™˜ํ•ด์•ผ ํ•œ๋‹ค.  ํ‹€๋ฆฐ ์ฝ”๋“œclas..
๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช… ๐Ÿ’ก 2. ์ •๋‹ต์ฝ”๋“œ๐Ÿ™…๐Ÿปโ€โ™€๏ธ ์ฒซ ๋ฒˆ์งธ ์‹œ๋„ - ํ‹€๋ฆผ โŒํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ˜์†”์ด ์ž๋™์™„์„ฑ์ด ์•ˆ ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ƒ๊ฐ๋‚˜๋Š”๋ฐ๋กœ ์จ์„œ ๋งŽ์ด ํ‹€๋ ธ๋‹ค.class Solution {    public String solution(String str1, String str2) {        StringBuilder sb = new StringBuilder();        for(int i = 0; i   ์˜ค๋‹ต ์ •๋ฆฌโญ str1.length โ†’ str1.length() length๋Š” ๋ฐฐ์—ด์—์„œ ์‚ฌ์šฉ๋˜๊ณ , ๋ฌธ์ž์—ด์—์„œ๋Š” length() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. โญ  sb.add(...) โ†’ sb.append(...)StringBuilder๋Š” add() ๋ฉ”์„œ๋“œ๊ฐ€ ์—†๊ณ , ๋Œ€์‹  append()๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค.โญ  st..
๐Ÿ“‘ 1. ๋ฌธ์ œ์„ค๋ช…โญ 2. ์ •๋‹ต์ฝ”๋“œclass Solution { public String solution(String my_string, String overwrite_string, int s) { // ์•ž๋ถ€๋ถ„๊ณผ ๋’ท๋ถ€๋ถ„์„ ์ถ”์ถœํ•œ ํ›„ overwrite_string์„ ์ค‘๊ฐ„์— ์‚ฝ์ž… String before = my_string.substring(0, s); String after = my_string.substring(s + overwrite_string.length()); return before + overwrite_string + after; }} โญ String before = my_string.substring(0, s); ์—์„œ substr..
โœ… session ๊ด€๋ฆฌโœ… logout.jspโœ… main.jsp ๋งŒ๋“ค๊ธฐ ์ง€๊ธˆ๊นŒ์ง€ ํšŒ์›๊ฐ€์ž…, ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ๊นŒ์ง€ ๊ตฌํ˜„ํ•ด๋ณด์•˜๋‹ค.์ด์ œ ์„ธ์…˜ ๊ด€๋ฆฌ๋ฅผ ํ•ด ๋ณด์ž. `session` ์ด๋ž€ ํ˜„์žฌ ์ ‘์†ํ•œ ํšŒ์›์—๊ฒŒ ํ• ๋‹นํ•ด์ฃผ๋Š” ๊ณ ์œ ํ•œ ์•„์ด๋””์ด๋‹ค.๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ•œ ํšŒ์›์—๊ฒŒ ๊ฐ๊ฐ `session`์„ ๋ถ€์—ฌํ•ด์ฃผ๋Š” ๊ณผ์ •์„ ๊ตฌํ˜„ํ•ด๋ณด์ž. `loginAction.jsp`์— `session`์„ ์„ค์ •ํ•ด์ฃผ๋Š” `session.setAttribute()` ์ฝ”๋“œ ํ•œ ์ค„ ํƒ€์ดํ•‘!`joinAction.jsp`์—๋„ ์ฝ”๋“œ ๋ณต๋ถ™ํ•ด์„œ ๋„ฃ์–ด ์ค€๋‹ค.๋กœ๊ทธ์ธ ์„ฑ๊ณตํ•œ ํšŒ์›์—๊ฒŒ ์„ธ์…˜ ๋ถ€์—ฌํ•˜๊ณ  ๋ฉ”์ธ ํŽ˜์ด์ง€๋กœ ๋„˜์–ด๊ฐ€๊ฒŒ๋” ํ•ด ์ค€๋‹ค. ์ด๋ ‡๊ฒŒ ์„ธ์…˜์„ ์„ค์ •ํ•ด ์ฃผ์—ˆ๋‹ค. ์„ธ์…˜์€ ํ•ด์ œ ํ•˜๊ธฐ ์ „๊นŒ์ง€๋Š” ์œ ํšจํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํ• ๋‹นํ•œ ์„ธ์…˜์„ ํ•ด์ œํ•  ์ˆ˜ ์žˆ๋Š” ๋กœ๊ทธ์•„์›ƒ ํŽ˜์ด์ง€๋„ ๋งŒ๋“ค์–ด ์ฃผ์ž. `joinAc..
์ €๋ฒˆ์— ํšŒ์›๊ฐ€์ž… ์–‘์‹ `join.jsp` ๊นŒ์ง€ ๋งŒ๋“ค์—ˆ๋‹ค. ์˜ค๋Š˜์€ userDAO ํด๋ž˜์Šค์— ํšŒ์›๊ฐ€์ž…์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฉ”์„œ๋“œ๋ฅผ ํ•˜๋‚˜ ์ถ”๊ฐ€ํ•ด ์ค„๊ฒƒ์ด๋‹ค.DAO ํด๋ž˜์Šค๋Š” ์‹ค์ œ๋กœ DB์— ์ ‘๊ทผํ•ด์„œ ์–ด๋–ค ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ค๊ฑฐ๋‚˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋„ฃ๋Š” ์—ญํ• ์„ ํ•˜๋Š” ๋ฐ์ดํ„ฐ ์ ‘๊ทผ ๊ฐ์ฒด์ด๋‹ค.๊ทธ๋ฆฌ๊ณ  ์ฒ˜๋ฆฌ๋œ ๊ฒฐ๊ณผ๊ฐ’์„ ๊ฐ€์ ธ์™€์„œ View ์ฒ˜๋ฆฌํ•˜๋Š” `join Action.jsp` ๊นŒ์ง€ ๋งŒ๋“ค์–ด ๋ณผ ๊ฒƒ์ด๋‹ค.   ๋จผ์ € userDAO ํด๋ž˜์Šค๋กœ ๊ฐ„๋‹ค.login ๋ฉ”์„œ๋“œ ์•„๋ž˜์— join ๋ฉ”์„œ๋“œ๋ฅผ ๋งŒ๋“ค์–ด ์ค€๋‹ค.// ํšŒ์›๊ฐ€์ž… ์ฒ˜๋ฆฌ ๋กœ์ง public int join(User user) { String SQL = "INSERT INTO USER VALUES(?, ?, ?, ?, ?)"; try { psmt = conn.prepareStatem..
์ƒ๋‹จ์œผ๋กœ