{"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":"%e0%b8%aa%e0%b8%95%e0%b8%a3%e0%b8%b4%e0%b8%87%e0%b8%88%e0%b8%b2%e0%b8%a7%e0%b8%b2","status":"publish","type":"post","link":"https:\/\/chat-messenger.com\/th\/blog\/java\/java-string","title":{"rendered":"\u0e2a\u0e23\u0e38\u0e1b\u0e01\u0e32\u0e23\u0e08\u0e31\u0e14\u0e01\u0e32\u0e23\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e02\u0e31\u0e49\u0e19\u0e1e\u0e37\u0e49\u0e19\u0e10\u0e32\u0e19\u0e43\u0e19\u0e20\u0e32\u0e29\u0e32 Java"},"content":{"rendered":"<h2>\u0e01\u0e32\u0e23\u0e41\u0e22\u0e01\u0e2a\u0e15\u0e23\u0e34\u0e07 \u2013 <strong>\u0e08\u0e38\u0e14<\/strong><\/h2>\n<p>\u0e04\u0e33\u0e2a\u0e31\u0e48\u0e07\u0e19\u0e35\u0e49\u0e43\u0e0a\u0e49\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e41\u0e22\u0e01\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e42\u0e14\u0e22\u0e43\u0e0a\u0e49\u0e15\u0e31\u0e27\u0e04\u0e31\u0e48\u0e19\u0e17\u0e35\u0e48\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e44\u0e27\u0e49<\/p>\n<h4>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e42\u0e04\u0e49\u0e14<\/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>\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49:<\/p>\n<pre class=\"console\">\r\n\u0e41\u0e2d\u0e1b\u0e40\u0e1b\u0e34\u0e49\u0e25 \u0e02\u0e49\u0e32\u0e27\u0e42\u0e1e\u0e14 \u0e01\u0e25\u0e49\u0e27\u0e22\r\n<\/pre>\n<h2>\u0e01\u0e32\u0e23\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e1e\u0e37\u0e49\u0e19\u0e10\u0e32\u0e19<\/h2>\n<p>\u0e04\u0e38\u0e13\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e43\u0e0a\u0e49\u0e15\u0e31\u0e27\u0e14\u0e33\u0e40\u0e19\u0e34\u0e19\u0e01\u0e32\u0e23 &quot;+&quot; \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e44\u0e14\u0e49<\/p>\n<h4>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e42\u0e04\u0e49\u0e14<\/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>\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49:<\/p>\n<pre class=\"console\">\r\n\u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35\u0e0a\u0e32\u0e27\u0e42\u0e25\u0e01!\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>\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d\u0e02\u0e49\u0e2d\u0e04\u0e27\u0e32\u0e21\u0e42\u0e14\u0e22\u0e43\u0e0a\u0e49\u0e15\u0e31\u0e27\u0e04\u0e31\u0e48\u0e19 <strong>\u0e18\u0e35\u0e21:<\/strong><\/h2>\n<p>\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e19\u0e35\u0e49\u0e43\u0e0a\u0e49\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e42\u0e14\u0e22\u0e43\u0e0a\u0e49\u0e15\u0e31\u0e27\u0e04\u0e31\u0e48\u0e19\u0e40\u0e09\u0e1e\u0e32\u0e30 (\u0e21\u0e35\u0e43\u0e2b\u0e49\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e43\u0e19 Java 8 \u0e41\u0e25\u0e30\u0e40\u0e27\u0e2d\u0e23\u0e4c\u0e0a\u0e31\u0e19\u0e17\u0e35\u0e48\u0e43\u0e2b\u0e21\u0e48\u0e01\u0e27\u0e48\u0e32)<\/p>\n<h4>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e42\u0e04\u0e49\u0e14<\/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>\u0e15\u0e31\u0e27\u0e14\u0e33\u0e40\u0e19\u0e34\u0e19\u0e01\u0e32\u0e23 join \u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e43\u0e0a\u0e49\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e0a\u0e37\u0e48\u0e2d\u0e21\u0e15\u0e48\u0e2d\u0e2d\u0e32\u0e23\u0e4c\u0e40\u0e23\u0e22\u0e4c\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e44\u0e14\u0e49\u0e43\u0e19\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e40\u0e14\u0e35\u0e22\u0e27\u0e01\u0e31\u0e19<\/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>\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49:<\/p>\n<pre class=\"console\">\r\n\u0e41\u0e2d\u0e1b\u0e40\u0e1b\u0e34\u0e49\u0e25 \u0e2a\u0e49\u0e21 \u0e01\u0e25\u0e49\u0e27\u0e22\r\n<\/pre>\n<h2>\u0e14\u0e36\u0e07\u0e02\u0e49\u0e2d\u0e04\u0e27\u0e32\u0e21\u0e08\u0e32\u0e01\u0e0a\u0e48\u0e27\u0e07\u0e17\u0e35\u0e48\u0e01\u0e33\u0e2b\u0e19\u0e14 <strong>\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e22\u0e48\u0e2d\u0e22<\/strong><\/h2>\n<p>\u0e04\u0e38\u0e13\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e23\u0e30\u0e1a\u0e38\u0e08\u0e38\u0e14\u0e40\u0e23\u0e34\u0e48\u0e21\u0e15\u0e49\u0e19\u0e41\u0e25\u0e30\u0e08\u0e38\u0e14\u0e2a\u0e34\u0e49\u0e19\u0e2a\u0e38\u0e14\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e14\u0e36\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 \u0e41\u0e25\u0e30\u0e14\u0e36\u0e07\u0e2a\u0e48\u0e27\u0e19\u0e2b\u0e19\u0e36\u0e48\u0e07\u0e02\u0e2d\u0e07\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e2d\u0e2d\u0e01\u0e21\u0e32\u0e44\u0e14\u0e49<\/p>\n<h4>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e42\u0e04\u0e49\u0e14<\/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>\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49:<\/p>\n<pre class=\"console\">\r\n\u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35\u0e0a\u0e32\u0e27\u0e42\u0e25\u0e01!\r\n<\/pre>\n<h2>\u0e25\u0e1a\u0e0a\u0e48\u0e2d\u0e07\u0e27\u0e48\u0e32\u0e07\u0e14\u0e49\u0e32\u0e19\u0e2b\u0e19\u0e49\u0e32\u0e41\u0e25\u0e30\u0e14\u0e49\u0e32\u0e19\u0e2b\u0e25\u0e31\u0e07\u0e2d\u0e2d\u0e01 <strong>\u0e15\u0e31\u0e14\u0e41\u0e15\u0e48\u0e07<\/strong><\/h2>\n<p>\u0e25\u0e1a\u0e0a\u0e48\u0e2d\u0e07\u0e27\u0e48\u0e32\u0e07\u0e19\u0e33\u0e2b\u0e19\u0e49\u0e32\u0e41\u0e25\u0e30\u0e15\u0e48\u0e2d\u0e17\u0e49\u0e32\u0e22 \u0e01\u0e32\u0e23\u0e02\u0e36\u0e49\u0e19\u0e1a\u0e23\u0e23\u0e17\u0e31\u0e14\u0e43\u0e2b\u0e21\u0e48 \u0e41\u0e25\u0e30\u0e41\u0e17\u0e47\u0e1a\u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01\u0e02\u0e49\u0e2d\u0e04\u0e27\u0e32\u0e21<br \/>\n\u0e0a\u0e48\u0e2d\u0e07\u0e27\u0e48\u0e32\u0e07\u0e41\u0e25\u0e30\u0e0a\u0e48\u0e2d\u0e07\u0e27\u0e48\u0e32\u0e07\u0e40\u0e15\u0e47\u0e21\u0e04\u0e27\u0e32\u0e21\u0e01\u0e27\u0e49\u0e32\u0e07\u0e20\u0e32\u0e22\u0e43\u0e19\u0e02\u0e49\u0e2d\u0e04\u0e27\u0e32\u0e21\u0e08\u0e30\u0e44\u0e21\u0e48\u0e16\u0e39\u0e01\u0e25\u0e1a\u0e2d\u0e2d\u0e01<\/p>\n<h4>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e42\u0e04\u0e49\u0e14<\/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>\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49:<\/p>\n<pre class=\"console\">\r\n\u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35\u0e0a\u0e32\u0e27\u0e42\u0e25\u0e01!\r\n<\/pre>\n<h2>\u0e41\u0e17\u0e19\u0e17\u0e35\u0e48\u0e2a\u0e48\u0e27\u0e19\u0e2b\u0e19\u0e36\u0e48\u0e07\u0e02\u0e2d\u0e07\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e14\u0e49\u0e27\u0e22\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e2d\u0e37\u0e48\u0e19 <strong>\u0e41\u0e17\u0e19\u0e17\u0e35\u0e48<\/strong><\/h2>\n<p>\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e19\u0e19\u0e35\u0e49\u0e08\u0e30\u0e41\u0e17\u0e19\u0e17\u0e35\u0e48\u0e2a\u0e48\u0e27\u0e19\u0e2b\u0e19\u0e36\u0e48\u0e07\u0e02\u0e2d\u0e07\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e14\u0e49\u0e27\u0e22\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e17\u0e35\u0e48\u0e23\u0e30\u0e1a\u0e38 `replace` \u0e08\u0e30\u0e41\u0e17\u0e19\u0e17\u0e35\u0e48\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14\u0e17\u0e35\u0e48\u0e15\u0e23\u0e07\u0e01\u0e31\u0e19<\/p>\n<h4>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e42\u0e04\u0e49\u0e14<\/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>\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49:<\/p>\n<pre class=\"console\">\r\nhe\u00d7\u00d7o word!\r\n<\/pre>\n<p>`replaceFirst` \u0e08\u0e30\u0e41\u0e17\u0e19\u0e17\u0e35\u0e48\u0e40\u0e09\u0e1e\u0e32\u0e30\u0e2a\u0e15\u0e23\u0e34\u0e07\u0e41\u0e23\u0e01\u0e17\u0e35\u0e48\u0e15\u0e23\u0e07\u0e01\u0e31\u0e19\u0e40\u0e17\u0e48\u0e32\u0e19\u0e31\u0e49\u0e19<\/p>\n<h4>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e42\u0e04\u0e49\u0e14<\/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>\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49:<\/p>\n<pre class=\"console\">\r\n\u0e2a\u0e27\u0e31\u0e2a\u0e14\u0e35\u0e42\u0e25\u0e01!\r\n<\/pre>\n<h2>\u0e2a\u0e48\u0e07\u0e04\u0e37\u0e19\u0e08\u0e33\u0e19\u0e27\u0e19\u0e2d\u0e31\u0e01\u0e02\u0e23\u0e30\u0e43\u0e19\u0e2a\u0e15\u0e23\u0e34\u0e07 <strong>\u0e02\u0e19\u0e32\u0e14<\/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>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e42\u0e04\u0e49\u0e14<\/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>\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49:<\/p>\n<pre class=\"console\">\r\n14\r\n<\/pre>\n<p>\u0e2b\u0e32\u0e01\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e17\u0e23\u0e32\u0e1a\u0e08\u0e33\u0e19\u0e27\u0e19\u0e44\u0e1a\u0e15\u0e4c \u0e43\u0e2b\u0e49\u0e43\u0e0a\u0e49 String.getBytes().length \u0e40\u0e19\u0e37\u0e48\u0e2d\u0e07\u0e08\u0e32\u0e01 Java 8 \u0e43\u0e0a\u0e49 UTF8 \u0e40\u0e1b\u0e47\u0e19\u0e01\u0e32\u0e23\u0e40\u0e02\u0e49\u0e32\u0e23\u0e2b\u0e31\u0e2a\u0e2d\u0e31\u0e01\u0e02\u0e23\u0e30\u0e40\u0e23\u0e34\u0e48\u0e21\u0e15\u0e49\u0e19 \u0e14\u0e31\u0e07\u0e19\u0e31\u0e49\u0e19\u0e2d\u0e31\u0e01\u0e02\u0e23\u0e30\u0e40\u0e15\u0e47\u0e21\u0e04\u0e27\u0e32\u0e21\u0e01\u0e27\u0e49\u0e32\u0e07\u0e41\u0e15\u0e48\u0e25\u0e30\u0e15\u0e31\u0e27\u0e08\u0e36\u0e07\u0e43\u0e0a\u0e49 3 \u0e44\u0e1a\u0e15\u0e4c<\/p>\n<h4>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e42\u0e04\u0e49\u0e14<\/h4>\n<pre class=\"sample_src\">\r\npublic static void byteLengthSample() { String str = &quot;\u3007\u3007 \u0e08\u0e31\u0e07\u0e2b\u0e27\u0e31\u0e14 \u25a1\u25a1 \u0e40\u0e21\u0e37\u0e2d\u0e07 \u25b3\u25b3 \u0e15\u0e33\u0e1a\u0e25 10-11&quot;; System.out.println(str.getBytes().length); }\r\n<\/pre>\n<p>\u0e1c\u0e25\u0e25\u0e31\u0e1e\u0e18\u0e4c\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49:<\/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\/th\/wp-json\/wp\/v2\/posts\/4617","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/comments?post=4617"}],"version-history":[{"count":8,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/posts\/4617\/revisions"}],"predecessor-version":[{"id":4628,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/posts\/4617\/revisions\/4628"}],"wp:attachment":[{"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/media?parent=4617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/categories?post=4617"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chat-messenger.com\/th\/wp-json\/wp\/v2\/tags?post=4617"}],"curies":[{"name":"\u0e14\u0e31\u0e1a\u0e40\u0e1a\u0e34\u0e25\u0e22\u0e39\u0e1e\u0e35","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}