๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ˜์‘ํ˜•

๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ96

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JAVA] ์™„์ฃผํ•˜์ง€ ๋ชปํ•œ ์„ ์ˆ˜ - ํ•ด์‹œ 1. Sort ์ฐธ์—ฌ์ž์™€ ์™„์ฃผ์ž Array๋ฅผ ์ •๋ ฌํ•œ ํ›„ ๊ฐ’์„ ๋น„๊ตํ•˜๋Š” ๋ฐฉ๋ฒ• ์ž…์ถœ๋ ฅ ์˜ˆ์˜ ์„ธ๋ฒˆ์งธ ๊ฒฝ์šฐ๋ฅผ sortํ•˜๋ฉด participant๋Š” ana | mislav | mislav | stanko โ–ผ -------------- ์ผ์น˜ํ•˜์ง€ ์•Š์Œ completion๋Š” ana | mislav | stanko import java.util.Arrays; class Solution { public String solution(String[] participant, String[] completion) { Arrays.sort(participant); Arrays.sort(completion); int i; for (i = 0; i < completion.length; i++) { if (!participant[i].eq.. 2022. 2. 18.
[JAVA] ๊ฐ์ฒด ๋ณต์ œ(clone)์™€ Shallow Copy, Deep Copy ๊ฐ์ฒด๋ฅผ ๋ณต์ œํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” Cloneable์„ ๊ตฌํ˜„ํ•˜๊ณ , clone() ๋ฉ”์†Œ๋“œ๋ฅผ ์˜ค๋ฒ„๋ผ์ด๋“œํ•˜๋ฉด ๋˜์„œ ๊ฐ„๋‹จํ•˜๋‹ค! @Getter @Setter public class Person implements Cloneable{ private String name; private int age; @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } } ๊ทธ๋ฆฌ๊ณ  ์•„๋ž˜์™€ ๊ฐ™์ด person1.clone(); ์„ ์‚ฌ์šฉํ•˜์—ฌ person1์˜ ๊ฐ์ฒด๋ฅผ ๋ณต์ œํ•˜์˜€๋‹ค. Person person1 = new Person(); person1.setName("ํ™๊ธธ๋™"); person1.setAge(30); try { Person pers.. 2022. 2. 16.
[Eclipse/STS] Marketplace์—์„œ Decompiler ์„ค์น˜ํ•˜๊ธฐ ์ง€๋‚œ์ฃผ์— jadClipse๋ฅผ ์ด์šฉํ•˜์—ฌ ๋””์ปดํŒŒ์ผ์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์„ ํฌ์ŠคํŒ…ํ–ˆ์—ˆ๋Š”๋ฐ.. ์ ์šฉ์ด ์ž˜ ๋ ๋•Œ๋„ ์žˆ๊ณ  ์•ˆ๋ ๋•Œ๋„ ์žˆ์–ด์„œ ์ƒˆ๋กœ์šด ๋ฐฉ๋ฒ•์„ ์ฐพ์•˜๋‹ค. [Eclipse/STS] Decompiler Plugin ์ ์šฉํ•˜๊ธฐ ์ธํ…”๋ฆฌ์ œ์ด์—์„  ๊ธฐ๋ณธ์ ์œผ๋กœ ๋””์ปดํŒŒ์ผํ•ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์— ๊ฐœ๋ฐœํ•  ๋•Œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์†Œ์Šค๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์–ด์„œ ํŽธ๋ฆฌํ–ˆ๋‹ค ๋ฐ˜๋ฉด ์ดํด๋ฆฝ์Šค๋‚˜ STS์—์„  ๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณตํ•ด์ฃผ์ง€ ์•Š์•„ ์ธํ…”๋ฆฌ์ œ์ด๋ฅผ ์“ฐ๋‹ค ๋Œ์•„์˜ค๋‹ˆ ๋ถˆ ynzu-dev.tistory.com 1. ์ดํด๋ฆฝ์Šค ๋งˆ์ผ“ํ”Œ๋ ˆ์ด์Šค์—์„œ Enghanced Class Decompiler ์„ค์น˜ (help>Eclipse Marketplace) 2. Decompiler์˜ Default Class Decompiler๋ฅผ FernFlower๋กœ ์„ ํƒ 3. *.class, *class without sou.. 2022. 2. 16.
[JAVA] ์‹ฑ๊ธ€ํ†ค ํŒจํ„ด(Singleton Pattern) : ๋ฉ€ํ‹ฐ ์Šค๋ ˆ๋“œ ํ™˜๊ฒฝ์—์„œ์˜ ๋ฌธ์ œ์  ์‹ฑ๊ธ€ํ†ค ํŒจํ„ด์ด๋ž€? ํ•œ๋งˆ๋””๋กœ ์ •์˜ํ•˜์ž๋ฉด '๊ฐ์ฒด๋ฅผ ๋‹จ ํ•˜๋‚˜๋งŒ ์ƒ์„ฑํ•˜๋„๋ก ํ•˜๋Š” ๋””์ž์ธ ํŒจํ„ด'! static์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ณ ์ •๋œ ๋ฉ”๋ชจ๋ฆฌ ์˜์–ต์„ ์–ป์œผ๋ฉฐ, ๋ชจ๋“  ํด๋ผ์ด์–ธํŠธ(ํด๋ž˜์Šค)์—์„œ ํ•ด๋‹น ์ธ์Šคํ„ด์Šค๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์–ด์„œ ๊ณตํ†ต๋œ ๊ฐ์ฒด๋ฅผ ๋‹ค์ˆ˜์˜ ํด๋ผ์ด์–ธํŠธ์—์„œ ์‚ฌ์šฉํ•ด์•ผํ•˜๋Š” ์ƒํ™ฉ์—์„œ ์ฃผ๋กœ ์‚ฌ์šฉ ๋œ๋‹ค. ์‹ฑ๊ธ€ํ†ค ํŒจํ„ด์˜ ์˜ˆ์ œ๋ฅผ ๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ํ˜•ํƒœ๊ฐ€ ๋Œ€๋ถ€๋ถ„์ด๋‹ค. ๋ณธ์ธ๋„ ์‹ฑ๊ธ€ํ†ค ํด๋ž˜์Šค๋ฅผ ์ž‘์„ฑํ•  ๋•Œ ์ด๋ ‡๊ฒŒ ์ž‘์„ฑํ•˜์˜€๋Š”๋ฐ, ์ด๋Ÿฐ ๊ฒฝ์šฐ ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ํ™˜๊ฒฝ์—์„  ๋‘๊ฐœ ์ด์ƒ์˜ ์Šค๋ ˆ๋“œ๊ฐ€ getInstance()๋ฅผ ํ•˜๊ฒŒ ๋  ๊ฒฝ์šฐ ๋‘๊ฐœ์˜ ์ธ์Šคํ„ด์Šค๊ฐ€ ์ƒ์„ฑ๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธธ ์ˆ˜ ์žˆ๋‹ค. (= ๋™์‹œ์„ฑ ๋ฌธ์ œ, thread unsafe) public class Singleton { private static Singleton singleton = null; pri.. 2022. 2. 10.
[Eclipse/STS] Decompiler Plugin ์ ์šฉํ•˜๊ธฐ ์ธํ…”๋ฆฌ์ œ์ด์—์„  ๊ธฐ๋ณธ์ ์œผ๋กœ ๋””์ปดํŒŒ์ผํ•ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์— ๊ฐœ๋ฐœํ•  ๋•Œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์†Œ์Šค๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์–ด์„œ ํŽธ๋ฆฌํ–ˆ๋‹ค ๋ฐ˜๋ฉด ์ดํด๋ฆฝ์Šค๋‚˜ STS์—์„  ๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณตํ•ด์ฃผ์ง€ ์•Š์•„ ์ธํ…”๋ฆฌ์ œ์ด๋ฅผ ์“ฐ๋‹ค ๋Œ์•„์˜ค๋‹ˆ ๋ถˆํŽธํ•จ์„ ๋งŽ์ด ๋Š๊ผˆ๊ณ .. ์˜ˆ์ „์— ๋””์ปดํŒŒ์ผํ•ด์ฃผ๋Š” ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ์žˆ๋‹ค๊ณ  ๋“ค์€ ๊ธฐ์–ต์ด ์žˆ์–ด ์„œ์น˜ํ•ด๋ณด์•˜๋‹ค! 1. ํ”Œ๋Ÿฌ๊ทธ์ธ ๋ฐ jad.exe ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ plugin : https://sourceforge.net/projects/jadclipse/ jad.exe : http://varaneckas.com/jad/ ์œ„ url์—์„œ ๋‹ค์šด๋ฐ›์€ jad.exe๋Š” ์ž‘๋™ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค๊ณ  ํ•˜๋‹ˆ.. ์•ˆ๋˜๋Š” ๊ฒฝ์šฐ ์•„๋ž˜ ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์œผ๋ฉด ๋œ๋‹ค~! 2. net.sf.jadclipse_3.3.0.jar ํŒŒ์ผ plugin ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์€ .. 2022. 2. 9.
[Eclipse] import ์—๋Ÿฌ : No projects are found to import ํ”„๋กœ์ ํŠธ ํŒŒ์ผ ๋‚ด๋ถ€์— .project, .classpath์™€ ๊ฐ™์€ ํŒŒ์ผ์ด ์—†์œผ๋ฉด eclipse ํ˜น์€ sts์—์„œ ํ”„๋กœ์ ํŠธ๋กœ ์ธ์‹ํ•˜์ง€ ๋ชปํ•ด์„œ importํ•  ๋•Œ 'No projects are found to import' ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. ์ด๋Ÿด ๊ฒฝ์šฐ File>Import๊ฐ€ ์•„๋‹Œ File>Open Projects from File System ์„ ํ†ตํ•ด ํ”„๋กœ์ ํŠธ๋ฅผ ๋ถˆ๋Ÿฌ์™€์•ผ ํ•œ๋‹ค. Directory ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ํ”„๋กœ์ ํŠธ๋ฅผ ์„ ํƒํ•œ ๋’ค Finish ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ํ”„๋กœ์ ํŠธ๊ฐ€ ๋ถˆ๋Ÿฌ์™€์ง„ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. 2022. 2. 8.
[JAVA] Priority Queue(์šฐ์„ ์ˆœ์œ„ ํ) ์šฐ์„ ์ˆœ์œ„ ์กฐ๊ฑด ๋ณ€๊ฒฝํ•˜๊ธฐ Priority Queue FIFO(First In First Out)์ธ ์ผ๋ฐ˜์ ์ธ Queue์™€ ๋‹ค๋ฅด๊ฒŒ Priority Queue๋Š” ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋†’์€ ๋ฐ์ดํ„ฐ๊ฐ€ ๋จผ์ € Out๋œ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌ์„ ํ•˜๊ฒŒ ๋˜๋Š”๋ฐ ์ •๋ ฌ ๊ธฐ์ค€์„ ๋ฐ”๊พธ๊ณ  ์‹ถ๋‹ค๋ฉด ๋žŒ๋‹ค์‹์„ ์ด์šฉํ•˜๊ฑฐ๋‚˜ Comparator, Comparable๋ฅผ ์ด์šฉํ•ด์•ผ ํ•œ๋‹ค. Integer๋Š” Collections.reverseOrder()๋ฅผ ํ†ตํ•ด ๊ฐ„๋‹จํ•˜๊ฒŒ ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ์„ ํ•  ์ˆ˜ ์žˆ๋‹ค. PriorityQueue pq = new PriorityQueue(Collections.reverseOrder()); pq.add(5); pq.add(7); pq.add(10); pq.add(3); System.out.println(pq.poll()); // 10 ์ถœ๋ ฅ add๊ฐ€ ์•„๋‹Œ.. 2022. 2. 7.
[Spring] Bean ๋“ฑ๋ก ๋ฐฉ๋ฒ• : @Bean vs @Component ์ฐจ์ด Spring์ด ๊ฐ์ฒด๋ฅผ ์ œ์–ดํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๊ฐ์ฒด๋“ค์ด Bean์œผ๋กœ ๋“ฑ๋ก๋˜์–ด ์žˆ์–ด์•ผ ํ•œ๋‹ค. ๊ธฐ์กด์—” xml์„ ํ†ตํ•ด bean์œผ๋กœ ๋“ฑ๋กํ–ˆ๋Š”๋ฐ Spring MVC์—์„œ๋Š” @Controller, @Service, @Repository ๋“ฑ์˜ ์–ด๋…ธํ…Œ์ด์…˜์„ ํ†ตํ•ด Spring Container์— Bean์œผ๋กœ ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  Configuration ๊ด€๋ จ ๊ฐ์ฒด๋Š” @Bean๊ณผ @Component ์–ด๋…ธํ…Œ์ด์…˜์„ ํ†ตํ•ด Bean์œผ๋กœ ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ๋‹ค. ์—ฌ๊ธฐ์„œ @Bean๊ณผ @Component์˜ ์ฐจ์ด๋Š” ๋ฌด์—‡์ผ๊นŒ? @Bean ์ง์ ‘ ์ปจํŠธ๋กคํ•  ์ˆ˜ ์—†๋Š” ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ Bean์œผ๋กœ ๋“ฑ๋กํ•˜๊ณ  ์‹ถ์€ ๊ฒฝ์šฐ์— ์‚ฌ์šฉํ•œ๋‹ค. @Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) @Retention(Re.. 2022. 2. 3.
728x90
๋ฐ˜์‘ํ˜•