몰랐던 java11 기능

murkgom·2023년 8월 18일

Collection Factory Method

//before
Arrays.asList(e1, e2, e3, ...);

//after
List.of(e1, e2, e3, ...);
Map.of(
	"key1", e1,
	"key2", e2,
	"key3", e3);
Set.of(e1, e2, e3, ...);

New String method

//lines()
String[] arr = "a\nbb\nccc".lines().toArray();		//arr : ["a", "bb", "ccc"]

//strip : trim이 제거 못한 유니코드 공백들까지 제거

//repeat()
"abc".repeat(3);		//abcabcabc

1개의 댓글

comment-user-thumbnail
2023년 8월 18일

글 재미있게 봤습니다.

답글 달기