Java4 [JAVA] String ์ค๋ณต์ ๊ฑฐ Stream String str = "asdgaassdf"; - ๋ฌธ์์ด์ Character[]์ผ๋ก ๋ณํํด์ค์ผํจ char[] -> Chcaracter[]๋ณด๋ค string -> Character[]์ด ๋ ๊ฐ๋จํ๊ฑฐ ๊ฐ์ ์ด์ ๋ ๋ญ๊น Character[] charObjectArray = str.chars().mapToObj(c -> (char)c).toArray(Character[]::new); - ์ค๋ณต ์ ๊ฑฐ Stream characterStream = Arrays.stream(charObjectArray).distinct(); - String์ผ๋ก ๋ฆฌํด String result2 = characterStream.map(String::valueOf).collect(Collectors.joining()); - ํ๋ฐฉ์ ํฉ์น๋ฉด? .. 2022. 3. 22. [JAVA] Case Format ๋ณ๊ฒฝ (UPPER_CAMEL, LOWER_HYPEN...) google guava ์ฌ์ฉ google CaseFormat import import com.google.common.base.CaseFormat; ์ํ๋ ํฌ๋งท์ผ๋ก ๋ณ๊ฒฝ String upperCamelVndr = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, "text_test"); //TextTest ํฌ๋งท ์ข ๋ฅ //CaseFormat enum ๊ฐ๋ณด๋ฉด ์์ธํ๊ฒ ํ์ธ ๊ฐ๋ฅ LOWER_HYPHEN(CharMatcher.is('-'), "-") { String normalizeWord(String word) { return Ascii.toLowerCase(word); } String convert(CaseFormat format, String s) { if (for.. 2022. 3. 22. [JAVA] ๋๋ฌธ์ ์์ ๊ณต๋ฐฑ ์ถ๊ฐ String originText = "CocoHiByeHaha331"; String CapitalSpaceText = text.replaceAll("\\d+", "").replaceAll("(.)([A-Z])", "$1 $2"); -> Coco Hi Bye Haha ์ซ์ ์ ๊ฑฐ ํ ๋๋ฌธ์ ์์ ๋์ด์ฐ๊ธฐ ์ถ๊ฐ 2022. 3. 22. [JAVA] char ์ ๋ฆฌ ํ๋์ฉ ์ถ๊ฐ ์ ๋ฆฌํด๋๊ฐ ์์ 1. charAt(idx) ๋ฌธ์์ด์ index๋ฒ์งธ ์์น์ ์๋ character์ return String str = "Hello World"; char c = str.charAt(0); System.out.println("c==?"+c); //H //์ค์ ๊ตฌํ๋ถ // public char charAt(int index) { // if ((index = value.length)) { // throw new StringIndexOutOfBoundsException(index); // } // return value[index]; // } 2. String.toCharArray() ๋ฌธ์์ด์ charArray๋ก ๋ณํ String str1 = "Hello.. 2022. 3. 1. ์ด์ 1 ๋ค์