Skip to content

Instantly share code, notes, and snippets.

@choiseungho
choiseungho / NutritionFactsEx1.java
Created September 21, 2015 04:05
점층적 생성자 패턴
package com.tistory.seungdols.effetive.ex_1;
/**
* @PROJECT effectiveJava
* @PACKAGE com.tistory.seungdols.effetive.ex_1
* @WRITTER Administrator
* @DATE 2015-09-21
* @HISTORY
* @DISCRIPT
*/
@choiseungho
choiseungho / NutritionFactsEx2.java
Created September 21, 2015 04:08
자바빈 패턴 -일관성이 훼손 가능하고, 항상 변경이 가능하다.
package com.tistory.seungdols.effetive.ex_1;
/**
* @PROJECT effectiveJava
* @PACKAGE com.tistory.seungdols.effetive.ex_1
* @WRITTER Administrator
* @DATE 2015-09-21
* @HISTORY
* @DISCRIPT
*/
@choiseungho
choiseungho / Builder.java
Created September 21, 2015 04:10
생성자 Builder pattern
package com.tistory.seungdols.effetive.ex_1;
/**
* @PROJECT effectiveJava
* @PACKAGE com.tistory.seungdols.effetive.ex_1
* @WRITTER Administrator
* @DATE 2015-09-21
* @HISTORY
* @DISCRIPT
*/
@choiseungho
choiseungho / SingletonPattern.java
Created September 21, 2015 04:24
public final field를 이용한 싱글턴 패턴
public class SingletonPatternEx1 {
//public final field를 이용한 싱글턴 패턴
public static final SingletonPatternEx1 INSTANCE = new SingletonPatternEx1();
private SingletonPatternEx1() {
}
}
@choiseungho
choiseungho / SingletonPatternEx2.java
Created September 21, 2015 04:27
정적 팩토리를 이용한 Singleton
package com.tistory.seungdols.effetive.ex_1;
/**
* @PROJECT effectiveJava
* @PACKAGE com.tistory.seungdols.effetive.ex_1
* @WRITTER Administrator
* @DATE 2015-09-21
* @HISTORY
* @DISCRIPT
*/
@choiseungho
choiseungho / SingletonPatternEx3.java
Created September 21, 2015 04:36
Enum type을 이용한 싱글톤 패턴
package com.tistory.seungdols.effetive.ex_1;
/**
* @PROJECT effectiveJava
* @PACKAGE com.tistory.seungdols.effetive.ex_1
* @WRITTER Administrator
* @DATE 2015-09-21
* @HISTORY
* @DISCRIPT
*/
@choiseungho
choiseungho / SingletonSerialization.java
Created September 21, 2015 04:43
singleton class에 Serializable 클래스로 만들기
private Object readResolve()
{
//동일한 객체가 반환되도록 하는 동시에, 가짜 객체는 GC가 처리 하도록 함
return INSTANCE;
}
@choiseungho
choiseungho / FileRename.java
Last active November 26, 2015 12:31
Input data를 통한 파일 이름/확장자 변경
package com.tistory.seungdols.file.rename;
import java.io.File;
import java.util.Scanner;
/**
* @PROJECT effectiveJava
* @PACKAGE com.tistory.seungdols.File.rename
* @WRITTER Administrator
* @DATE 2015-09-21
@choiseungho
choiseungho / AddActionListnerlambda.java
Last active November 26, 2015 12:31
기존 리스너 추가와 람다식 사용의 차이 - what different use AddListner and Lambda?
btn_search.addActionListener(e -> {
btnAction(e);
});
btn_search.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
btnAction(e);
}
});
@choiseungho
choiseungho / GetFilePath.java
Last active November 26, 2015 12:31
Class의 디렉토리 경로를 가져오는 방법
String path = GetFilePath.class.getResource("").getPath();//현재 자신의 경로
String path = GetFilePath.class.getResource("/").getPath();//classes의 최상위 경로
new File("").getAbsolutePath();//절대 경로
new File("").getCanonicalPath();//상대 경로