{"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":"%ec%9e%90%eb%b0%94-%eb%ac%b8%ec%9e%90%ec%97%b4","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/ko\/blog\/java\/java-string","title":{"rendered":"Java\uc758 \uae30\ubcf8 \ubb38\uc790\uc5f4 \uc870\uc791 \uc694\uc57d"},"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() {\r\n    String line = \"\u308a\u3093\u3054,\u307f\u304b\u3093,\u30d0\u30ca\u30ca\";\r\n    String[] fruits = line.split(\",\");\r\n    for (String fruit : fruits) {\r\n        System.out.println(fruit);\r\n    }\r\n}\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() {\r\n    String line = String.join(\",\", \"\u308a\u3093\u3054\", \"\u307f\u304b\u3093\", \"\u30d0\u30ca\u30ca\");\r\n    System.out.println(line);\r\n}\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() {\r\n    String[] fruits = {\"\u308a\u3093\u3054\", \"\u307f\u304b\u3093\", \"\u30d0\u30ca\u30ca\"};\r\n    String line = String.join(\",\", fruits);\r\n    System.out.println(line); \/\/\u7d50\u679c\u306f\u540c\u3058\r\n}\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() {\r\n    String str = \"hello world!\";\r\n    System.out.println(str.substring(0, 5));\r\n    System.out.println(str.substring(2, 9));\r\n    System.out.println(str.substring(6)); \/\/\u59cb\u70b9\u3060\u3051\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\r\n}\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() {\r\n    String str = \"hello world!\";\r\n    System.out.println(str.replace(\"l\", \"\u00d7\"));\r\n}\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>\u6587\u5b57\u5217\u306e\u6587\u5b57\u6570\u3092\u8fd4\u3057\u307e\u3059\u3002String.length()\u306f\u5358\u7d14\u306b\u6587\u5b57\u6570\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<h4>\uc0d8\ud50c \ucf54\ub4dc<\/h4>\n<pre class=\"sample_src\">\r\npublic static void lengthSample() {\r\n    String str = \"\u3007\u3007\u770c\u25a1\u25a1\u5e02\u25b3\u25b3\u753a10-11\";\r\n    System.out.println(str.length());\r\n}\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>\u6587\u5b57\u5217\u3092\u5206\u5272\u3059\u308b &#8211; split \u7279\u5b9a\u306e\u6587\u5b57\u5217(\u30c7\u30ea\u30df\u30bf)\u3067\u6587\u5b57\u5217\u3092\u5206\u5272\u3057\u307e\u3059\u3002 \u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[19],"tags":[],"class_list":["post-4617","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/chat-messenger.com\/ko\/wp-json\/wp\/v2\/posts\/4617","targetHints":{"allow":["GET"]}}],"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}]}}