Skip to content

Instantly share code, notes, and snippets.

View minikuma's full-sized avatar
🖋️
Focusing

Jeon Jihoon minikuma

🖋️
Focusing
View GitHub Profile
@minikuma
minikuma / Foo1.java
Last active November 14, 2018 09:17
Constructor example-1
public class Foo {
public Foo() {
}
public static void main(String[] args) {
Foo foo = new Foo();
System.out.println("created foo: " + foo);
}
}
public static Boolean valueOf(boolean b) {
return b ? Boolean.TRUE : Boolean.FALSE;
}
/**************************************************************
Item01 장점1> static factory method에는 이름이 존재한다.
**************************************************************/
public class Drill {
private String id;
private int num;
//Constructor
public Drill() { }
public Drill(String id) {
/***********************************************************************
Item01 장점2> 객체를 호출 할 때마다 매번 새로운 객체를 생성할 필요는 없다.
***********************************************************************/
public class Drill {
private static final Drill GOOD_ID = new Drill.withId("minikuma");
private static final Drill GOOD_NUM = new Drill.withNum(100);
private String id;
private int num;
/**************************************************************
Item01 장점3> 해당 객체의 하위 타입을 리턴할 수 있다.
Item01 장점4> 리턴하는 객체의 클래스가 입력 매개변수에 따라 다른 리턴값을 갖게 할 수 있다.
*************************************************************/
public class Drill {
private String id;
private int num;
public Drill() { }
public class UniqueChars {
boolean isUniqueChars(String str) {
if (str.length() > 128) return false;
//미리 선언된 배열 -> 문자 요소가 등장할 때마다 메모하는 용도로 사용
boolean[] char_set = new boolean[128];
for (int i = 0; i < str.length(); i++) {
//각 문자열을 문자 요소로 변경
int val = str.charAt(i);
if (char_set[val]) {
return false;
public class Permutation {
boolean permutation(String s, String t) {
if (s.length() != t.length()) {
return false;
}
//memo 저장 공간
int[] marking = new int[128];
//첫 번째 문자열을 memo +1
char[] s_array = s.toCharArray();
for (char c : s_array) {
public class URLreplace {
static String replaceSpaces(String s, int len) {
int spaceCount = 0, index, i = 0;
char[] originStr = s.toCharArray();
for (i = 0; i < len; i++) {
if (originStr[i] == ' ') {
spaceCount++;
}
public class SpittrWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] {RootConfig.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] {WebConfig.class, SwaggerConfig.class}; //설정 클래스를 명시
}
@Controller
public class HomeController {
@RequestMapping(value = "/" ,method = RequestMethod.GET)
public String home() {
return "home"; //view name
}
}