๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

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.