{"id":4617,"date":"2019-10-19T13:31:09","date_gmt":"2019-10-19T04:31:09","guid":{"rendered":"https:\/\/chat-messenger.com\/?p=4617"},"modified":"2019-10-19T13:43:05","modified_gmt":"2019-10-19T04:43:05","slug":"java-string","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/ko\/blog\/java\/\uc790\ubc14-\ubb38\uc790\uc5f4","title":{"rendered":"\uc790\ubc14\uc758 \uae30\ubcf8 \ubb38\uc790\uc5f4 \uc870\uc791 \uc815\ub9ac"},"content":{"rendered":"<h2>\ubb38\uc790\uc5f4 \ubd84\ud560 \u2013 <strong>split<\/strong><\/h2>\n<p>\ud2b9\uc815 \ubb38\uc790\uc5f4 (\ubd84\ub9ac\uc790)\ub85c \ubb38\uc790\uc5f4\uc744 \ubd84\ud560\ud569\ub2c8\ub2e4.<\/p>\n<h4>\uc0d8\ud50c \ucf54\ub4dc<\/h4>\n<pre class=\"sample_src\">\r\npublic static void splitSample() { String line = &quot;\uc0ac\uacfc, \uade4, \ubc14\ub098\ub098&quot;; String[] fruits = line.split(&quot;,&quot;); for (String fruit : fruits) { System.out.println(fruit); } }\r\n<\/pre>\n<p>\ucd9c\ub825 \uacb0\uacfc:<\/p>\n<pre class=\"console\">\r\n\uc0ac\uacfc \ubbf8\uce78\ubc14\ub098\r\n<\/pre>\n<h2>\uae30\ubcf8 \ubb38\uc790\uc5f4 \uc870\uc778<\/h2>\n<p>&quot;+&quot; \uc5f0\uc0b0\uc790\ub85c \ubb38\uc790\uc5f4\uc744 \uacb0\ud569\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h4>\uc0d8\ud50c \ucf54\ub4dc<\/h4>\n<pre class=\"sample_src\">\r\npublic static void plusSample() { String s1 = &quot;hello &quot;; String s2 = &quot;world!&quot;; System.out.println(s1 + s2); }\r\n<\/pre>\n<p>\ucd9c\ub825 \uacb0\uacfc:<\/p>\n<pre class=\"console\">\r\nhello world!\r\n<\/pre>\n<p><script type=\"text\/javascript\" src=\"https:\/\/chat-messenger.com\/js\/common.js?dd12sssas2223\" charset=\"UTF-8\"><\/script><br \/>\n<script type=\"text\/javascript\"> writePR(); <\/script><\/p>\n<h2>\ubb38\uc790\uc5f4\uc744 \uad6c\ubd84\uc790\ub85c \uacb0\ud569 \u2013 <strong>\uc870\uc778<\/strong><\/h2>\n<p>\ud2b9\uc815 \ubb38\uc790\uc5f4 (\ubd84\ub9ac\uc790)\ub85c \ubb38\uc790\uc5f4\uc744 \uacb0\ud569\ud569\ub2c8\ub2e4 (java8 \uc774\uc0c1\uc5d0\uc11c \uc0ac\uc6a9 \uac00\ub2a5)<\/p>\n<h4>\uc0d8\ud50c \ucf54\ub4dc<\/h4>\n<pre class=\"sample_src\">\r\npublic static void joinSample() { String line = String.join(&quot;,&quot;, &quot;\uc0ac\uacfc&quot;, &quot;\uade4&quot;, &quot;\ubc14\ub098\ub098&quot;); System.out.println(line); }\r\n<\/pre>\n<p>join \uc740 \ubb38\uc790\uc5f4 \ubc30\uc5f4\uc5d0\uc11c\ub3c4 \uac19\uc740 \ubc29\uc2dd\uc73c\ub85c \uacb0\ud569\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"sample_src\">\r\npublic static void joinArraySample() { String[] fruits = {&quot;\uc0ac\uacfc&quot;, &quot;\uade4&quot;, &quot;\ubc14\ub098\ub098&quot;}; String line = String.join(&quot;,&quot;, fruits); System.out.println(line); \/ \/\uacb0\uacfc\ub294 \ub3d9\uc77c}\r\n<\/pre>\n<p>\ucd9c\ub825 \uacb0\uacfc:<\/p>\n<pre class=\"console\">\r\n\uc0ac\uacfc, \uade4, \ubc14\ub098\ub098\r\n<\/pre>\n<h2>\uc9c0\uc815\ub41c \ubc94\uc704\uc758 \ubb38\uc790\uc5f4\uc744 \uc798\ub77c\ub0c5\ub2c8\ub2e4. <strong>substring<\/strong><\/h2>\n<p>\uc798\ub77c\ub0b4\uae30\uc758 \uc2dc\uc791\uc810\uacfc \ub05d\uc810\uc744 \uc9c0\uc815\ud558\uc5ec \ubb38\uc790\uc5f4\uc744 \ubd80\ubd84\uc801\uc73c\ub85c \uc798\ub77c\ub0c5\ub2c8\ub2e4.<\/p>\n<h4>\uc0d8\ud50c \ucf54\ub4dc<\/h4>\n<pre class=\"sample_src\">\r\npublic static void substringSample() { String str = &quot;hello world!&quot;; System.out.println(str.substring(0, 5)); System.out.println(str.substring(2, 9)); System. out.println(str.substring(6)); \/\/ \uc2dc\uc791\uc810\ub9cc \uc9c0\uc815\ud560 \uc218\ub3c4 \uc788\uc2b5\ub2c8\ub2e4}\r\n<\/pre>\n<p>\ucd9c\ub825 \uacb0\uacfc:<\/p>\n<pre class=\"console\">\r\nhello llo wor world!\r\n<\/pre>\n<h2>\uc804\ud6c4\uc758 \uacf5\ubc31 \uc0ad\uc81c \u2013 <strong>trim<\/strong><\/h2>\n<p>\ubb38\uc790\uc5f4\uc758 \uc804\ud6c4\uc758 \ubc18\uac01 \uc2a4\ud398\uc774\uc2a4, \uac1c\ud589, \ud0ed\uc744 \uc81c\uac70\ud569\ub2c8\ub2e4.<br \/>\n\ubb38\uc790\uc5f4\uc758 \uc911\uac04\uc5d0 \uc788\ub294 \uacf5\ubc31\uc774\ub098 \uc804\uac01 \uacf5\ubc31\uc740 \uc81c\uac70\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/p>\n<h4>\uc0d8\ud50c \ucf54\ub4dc<\/h4>\n<pre class=\"sample_src\">\r\npublic static void trimSample() { String str = &quot; hello world! &quot;; System.out.println(str.trim()); }\r\n<\/pre>\n<p>\ucd9c\ub825 \uacb0\uacfc:<\/p>\n<pre class=\"console\">\r\nhello world!\r\n<\/pre>\n<h2>\ubb38\uc790\uc5f4\uc758 \uc77c\ubd80\ub97c \ub2e4\ub978 \ubb38\uc790\uc5f4\ub85c \ubc14\uafb8\uae30 \u2013 <strong>replace<\/strong><\/h2>\n<p>\ubb38\uc790\uc5f4\uc758 \uc77c\ubd80\ub97c \uc9c0\uc815\ub41c \ubb38\uc790\uc5f4\ub85c \ubc14\uafc9\ub2c8\ub2e4. replace\ub294 \uc77c\uce58\ud558\ub294 \ubaa8\ub4e0 \ubb38\uc790\uc5f4\uc744 \ub300\uccb4\ud569\ub2c8\ub2e4.<\/p>\n<h4>\uc0d8\ud50c \ucf54\ub4dc<\/h4>\n<pre class=\"sample_src\">\r\npublic static void replaceSample() { String str = &quot;hello world!&quot;; System.out.println(str.replace(&quot;l&quot;, &quot;\u00d7&quot;)); }\r\n<\/pre>\n<p>\ucd9c\ub825 \uacb0\uacfc:<\/p>\n<pre class=\"console\">\r\nhe\u00d7\u00d7o wor\u00d7d!\r\n<\/pre>\n<p>replaceFirst\ub294 \uc77c\uce58\ud558\ub294 \uccab \ubc88\uc9f8 \ubb38\uc790\uc5f4\ub9cc \ubc14\uafc9\ub2c8\ub2e4.<\/p>\n<h4>\uc0d8\ud50c \ucf54\ub4dc<\/h4>\n<pre class=\"sample_src\">\r\npublic static void replaceFirstSample() { String str = &quot;hello world!&quot;; System.out.println(str.replaceFirst(&quot;l&quot;, &quot;\u00d7&quot;)); }\r\n<\/pre>\n<p>\ucd9c\ub825 \uacb0\uacfc:<\/p>\n<pre class=\"console\">\r\nhe\u00d7lo world!\r\n<\/pre>\n<h2>\ubb38\uc790\uc5f4\uc758 \ubb38\uc790 \uc218\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4. <strong>\uae38\uc774<\/strong><\/h2>\n<p>\uce90\ub9ad\ud130 \ub77c\uc778\uc758 \uce90\ub9ad\ud130\uc218\ub97c \ub3cc\ub824\uc90d\ub2c8\ub2e4. String.length()\ub294 \ub2e8\uc21c\ud788 \ubb38\uc790 \uc218\ub97c \ubc18\ud658\ud569\ub2c8\ub2e4.<\/p>\n<h4>\uc0d8\ud50c \ucf54\ub4dc<\/h4>\n<pre class=\"sample_src\">\r\npublic static void lengthSample() { String str = &quot;\u3007\u3007\ud604 \u25a1\u25a1\uc2dc \u25b3\u25b3\ub9c8\uc744 10-11&quot;; System.out.println(str.length()); }\r\n<\/pre>\n<p>\ucd9c\ub825 \uacb0\uacfc:<\/p>\n<pre class=\"console\">\r\n14\r\n<\/pre>\n<p>\ubc14\uc774\ud2b8\uc218\uac00 \uc54c\uace0 \uc2f6\uc740 \uacbd\uc6b0\ub294 String.getBytes().length \ub97c \uc0ac\uc6a9\ud569\ub2c8\ub2e4. Java8\ubd80\ud130 \ubb38\uc790 \ucf54\ub4dc\ub294 \ud45c\uc900\uc73c\ub85c UTF8\uc774\ubbc0\ub85c, \uc804\uac01 \ubb38\uc790 1 \ubb38\uc790\ub2f9 3 \ubc14\uc774\ud2b8\uc785\ub2c8\ub2e4.<\/p>\n<h4>\uc0d8\ud50c \ucf54\ub4dc<\/h4>\n<pre class=\"sample_src\">\r\npublic static void byteLengthSample() { String str = &quot;\u3007\u3007\ud604 \u25a1\u25a1\uc2dc \u25b3\u25b3\ub9c8\uc744 10-11&quot;; System.out.println(str.getBytes().length); }\r\n<\/pre>\n<p>\ucd9c\ub825 \uacb0\uacfc:<\/p>\n<pre class=\"console\">\r\n32\r\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>\ubb38\uc790\uc5f4 \ubd84\ud560 \u2013 split \ud2b9\uc815 \ubb38\uc790\uc5f4(\ubd84\ub9ac\uc790)\ub85c \ubb38\uc790\uc5f4\uc744 \ubd84\ud560\ud569\ub2c8\ub2e4. \uc0d8\ud50c \ucf54\ub4dc [\u2026]<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":""},"categories":[19],"tags":[],"_links":{"self":[{"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/posts\/4617"}],"collection":[{"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/comments?post=4617"}],"version-history":[{"count":8,"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/posts\/4617\/revisions"}],"predecessor-version":[{"id":4628,"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/posts\/4617\/revisions\/4628"}],"wp:attachment":[{"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/media?parent=4617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/categories?post=4617"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/tags?post=4617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}