{"id":52191,"date":"2025-08-11T11:14:21","date_gmt":"2025-08-11T03:14:21","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/52191.html"},"modified":"2025-08-11T11:14:21","modified_gmt":"2025-08-11T03:14:21","slug":"string%e7%b1%bb%e7%9a%84%e5%ad%98%e5%82%a8%e7%bb%93%e6%9e%84%e4%b8%8e%e5%b8%b8%e7%94%a8%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/52191.html","title":{"rendered":"String\u7c7b\u7684\u5b58\u50a8\u7ed3\u6784\u4e0e\u5e38\u7528\u65b9\u6cd5"},"content":{"rendered":"<p>JAVA\u4e2d\u7684String\u7c7b\u662f\u7528\u4e8e\u5b58\u50a8\u5b57\u7b26\u4e32\u6570\u636e\u7684&#xff0c;C\u8bed\u8a00\u4e2d\u6ca1\u6709String\u7c7b\u578b&#xff0c;C\u8bed\u8a00\u4e2d\u4f7f\u7528char[]\u6570\u7ec4\u5b58\u50a8\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u672c\u6587\u6d89\u53caJVM\u7684\u5185\u5b58\u5212\u5206&#xff0c;\u4e0d\u4e86\u89e3\u7684\u8bfb\u8005\u53ef\u770bJVM\u2014\u2014Java\u865a\u62df\u673a-CSDN\u535a\u5ba2<\/p>\n<p>JAVA\u4e2d\u7684String\u5bf9\u8c61\u662f\u4e0d\u53ef\u53d8\u7684\u3002\u6ce8\u610f&#xff0c;\u8fd9\u91cc\u8bf4\u7684\u4e0d\u53ef\u53d8\u4e0d\u662f\u5b57\u7b26\u4e32\u7684\u5f15\u7528\u4e0d\u53ef\u53d8&#xff0c;\u800c\u662f\u5b57\u7b26\u4e32\u672c\u8eab\u4e0d\u53ef\u53d8\u3002\u4ee5\u4e0b\u9762\u7684\u4ee3\u7801\u4e3a\u4f8b&#xff1a;<\/p>\n<p>public static void main(String[] args) {<br \/>\n        String s1 &#061; &#034;Hello world!&#034;;<br \/>\n        s1 &#061; &#034;xixi&#034;;<br \/>\n        System.out.println(s1);<br \/>\n    } <\/p>\n<li>\n<p>\u5f53\u6267\u884c\u00a0String s1 &#061; &#034;Hello world!&#034;\u00a0\u65f6&#xff1a;<\/p>\n<ul>\n<li>JVM \u4f1a\u68c0\u67e5\u5e38\u91cf\u6c60&#xff0c;\u5982\u679c\u6ca1\u6709 &#034;Hello world!&#034;&#xff0c;\u5c31\u4f1a\u5728\u5e38\u91cf\u6c60\u4e2d\u521b\u5efa\u8be5\u5b57\u7b26\u4e32\u5bf9\u8c61<\/li>\n<li>\u8ba9 s1 \u5f15\u7528\u6307\u5411\u5e38\u91cf\u6c60\u4e2d\u7684 &#034;Hello world!&#034; \u5bf9\u8c61<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5f53\u6267\u884c\u00a0s1 &#061; &#034;xixi&#034;\u00a0\u65f6&#xff1a;<\/p>\n<ul>\n<li>JVM \u4f1a\u68c0\u67e5\u5e38\u91cf\u6c60&#xff0c;\u5982\u679c\u6ca1\u6709 &#034;xixi&#034;&#xff0c;\u5c31\u4f1a\u5728\u5e38\u91cf\u6c60\u4e2d\u521b\u5efa\u8be5\u5b57\u7b26\u4e32\u5bf9\u8c61<\/li>\n<li>\u8ba9 s1 \u5f15\u7528\u6307\u5411\u5e38\u91cf\u6c60\u4e2d\u7684 &#034;xixi&#034; \u5bf9\u8c61&#xff08;\u539f\u6765\u7684 &#034;Hello world!&#034; \u5bf9\u8c61\u4ecd\u7136\u5728\u5e38\u91cf\u6c60\u4e2d&#xff09;<\/li>\n<li><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"716\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811031417-68996009954c7.png\" width=\"1115\" \/><\/li>\n<\/ul>\n<\/li>\n<p>\u8fd9\u6837\u505a\u7684\u597d\u5904\u5c31\u662f\u540e\u9762\u4e00\u65e6\u518d\u6709\u4e00\u4e2aString\u5bf9\u8c61\u4ee5\u5e38\u91cf\u6c60\u4e2d\u6709\u7684\u503c\u8fdb\u884c\u521d\u59cb\u5316&#xff0c;\u5c31\u4e0d\u5fc5\u518d\u5f00\u8f9f\u989d\u5916\u7684\u7a7a\u95f4\u4e86&#xff0c;\u63d0\u9ad8\u4e86\u5185\u5b58\u590d\u7528\u3002<\/p>\n<h2>\u4e00.String\u7c7b\u7684\u6bd4\u8f83<\/h2>\n<p>\u76f4\u63a5\u4f7f\u7528&#061;&#061;\u8fdb\u884c\u6bd4\u8f83\u7684\u8bdd&#xff0c;\u6bd4\u8f83\u7684\u662f\u4e24\u4e2a\u5f15\u7528\u662f\u5426\u76f8\u7b49&#xff0c;\u5373\u5730\u5740\u662f\u5426\u76f8\u540c\u3002\u4e0e\u5176\u4ed6\u7c7b\u4e0d\u540c\u7684\u4e00\u70b9\u5728\u4e8e&#xff0c;\u7531\u4e8e\u5e38\u91cf\u6c60\u7684\u5b58\u5728&#xff0c;\u76f4\u63a5\u4f7f\u7528\u5b57\u7b26\u4e32\u5bf9String\u5f15\u7528\u8fdb\u884c\u521d\u59cb\u5316&#xff0c;\u5f15\u7528\u6307\u5411\u7684\u5730\u5740\u4f1a\u662f\u540c\u4e00\u5757\u3002\u4ee5\u4ee3\u7801\u4e3a\u4f8b&#xff1a;<\/p>\n<p>  public static void main(String[] args) {<br \/>\n        Student s1 &#061; new Student(&#034;zhangsan&#034;,10);<br \/>\n        Student s2 &#061; new Student(&#034;zhangsan&#034;,10);<br \/>\n        System.out.println(s2&#061;&#061;s1);\/\/false<br \/>\n        String s3 &#061; new String(&#034;haha&#034;);<br \/>\n        String s4 &#061; new String(&#034;haha&#034;);<br \/>\n        System.out.println(s3&#061;&#061;s4);\/\/false<br \/>\n        String s5 &#061; &#034;haha&#034;;<br \/>\n        String s6 &#061; &#034;haha&#034;;<br \/>\n        System.out.println(s5&#061;&#061;s6);\/\/true<br \/>\n    } <\/p>\n<p>\u7ed3\u679c&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"251\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811031418-6899600aeeb41.png\" width=\"751\" \/><\/p>\n<p>s3\u4e0es4\u7531\u4e8enew\u4e86\u4e24\u4e2a\u65b0\u5bf9\u8c61&#xff0c;\u8fd9\u4e24\u4e2a\u5bf9\u8c61\u5b58\u50a8\u5728\u5806\u4e0a\u3002\u4e24\u5757\u4e0d\u540c\u7684\u5730\u5740&#xff0c;\u5f15\u7528\u81ea\u7136\u4e0d\u540c\u3002<\/p>\n<p>s5\u548cs6\u76f4\u63a5\u5f15\u7528\u4e86\u5e38\u91cf\u6c60\u4e2d\u7684\u6570\u636e&#xff0c;\u56e0\u6b64\u5f15\u7528\u503c\u76f8\u540c&#xff0c;\u90fd\u50a8\u5b58\u201chaha\u201d\u6240\u5728\u5e38\u91cf\u6c60\u7684\u5730\u5740\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1079\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811031419-6899600b28da9.png\" width=\"1543\" \/><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528intern&#xff08;)\u65b9\u6cd5\u6765\u5c06\u5b57\u7b26\u4e32\u653e\u8fdb\u5e38\u91cf\u6c60\u4e2d\u3002<\/p>\n<p>public static void main(String[] args) {<br \/>\n        char[]ch &#061; new char[]{&#039;a&#039;,&#039;b&#039;,&#039;c&#039;};<br \/>\n        String s1 &#061; new String(ch);<br \/>\n        \/\/s1.intern();<br \/>\n        String s2 &#061;&#034;abc&#034;;<br \/>\n        System.out.println(s1 &#061;&#061; s2);<br \/>\n    } <\/p>\n<p>\u8fd9\u4e2a\u4ee3\u7801\u8f93\u51fa\u7ed3\u679c\u4e3afalse&#xff0c;\u4e00\u65e6\u89e3\u5f00\u6ce8\u91caintern(),\u7ed3\u679c\u5c31\u4e3atrue\u3002\u56e0\u4e3as1\u5f15\u7528\u7684\u503c\u88ab\u653e\u8fdb\u4e86\u5e38\u91cf\u6c60\u3002<\/p>\n<h2>\u4e8c.String\u7c7b\u7684\u5e38\u7528\u65b9\u6cd5<\/h2>\n<h4>\u4e00\u3001\u83b7\u53d6\u5b57\u7b26\u4e32\u4fe1\u606f<\/h4>\n<li>\n<p>length() \u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u957f\u5ea6&#xff08;\u5b57\u7b26\u4e2a\u6570&#xff09;\u3002<\/p>\n<p> String s &#061; &#034;hello&#034;;<br \/>\nSystem.out.println(s.length()); \/\/ \u8f93\u51fa&#xff1a;5\n <\/li>\n<li>\n<p>charAt(int index) \u8fd4\u56de\u6307\u5b9a\u7d22\u5f15\u4f4d\u7f6e\u7684\u5b57\u7b26&#xff08;\u7d22\u5f15\u4ece 0 \u5f00\u59cb&#xff09;\u3002<\/p>\n<p> String s &#061; &#034;hello&#034;;<br \/>\nSystem.out.println(s.charAt(1)); \/\/ \u8f93\u51fa&#xff1a;&#039;e&#039;\n <\/li>\n<li>\n<p>indexOf(String str) \u8fd4\u56de\u5b50\u5b57\u7b26\u4e32\u00a0str\u00a0\u5728\u5f53\u524d\u5b57\u7b26\u4e32\u4e2d\u7b2c\u4e00\u6b21\u51fa\u73b0\u7684\u7d22\u5f15&#xff0c;\u82e5\u4e0d\u5b58\u5728\u5219\u8fd4\u56de\u00a0-1\u3002<\/p>\n<p> String s &#061; &#034;hello world&#034;;<br \/>\nSystem.out.println(s.indexOf(&#034;lo&#034;)); \/\/ \u8f93\u51fa&#xff1a;3\n <\/li>\n<li>\n<p>lastIndexOf(String str) \u8fd4\u56de\u5b50\u5b57\u7b26\u4e32\u00a0str\u00a0\u5728\u5f53\u524d\u5b57\u7b26\u4e32\u4e2d\u6700\u540e\u4e00\u6b21\u51fa\u73b0\u7684\u7d22\u5f15&#xff0c;\u82e5\u4e0d\u5b58\u5728\u5219\u8fd4\u56de\u00a0-1\u3002<\/p>\n<p> String s &#061; &#034;hello world&#034;;<br \/>\nSystem.out.println(s.lastIndexOf(&#034;o&#034;)); \/\/ \u8f93\u51fa&#xff1a;7\n <\/li>\n<h4>\u4e8c\u3001\u5b57\u7b26\u4e32\u6bd4\u8f83<\/h4>\n<li>\n<p>equals(Object obj) \u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u662f\u5426\u76f8\u7b49&#xff08;\u533a\u5206\u5927\u5c0f\u5199&#xff09;\u3002<\/p>\n<p> String s1 &#061; &#034;hello&#034;;<br \/>\nString s2 &#061; &#034;Hello&#034;;<br \/>\nSystem.out.println(s1.equals(s2)); \/\/ \u8f93\u51fa&#xff1a;false\n <\/li>\n<li>\n<p>equalsIgnoreCase(String str) \u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u662f\u5426\u76f8\u7b49&#xff08;\u4e0d\u533a\u5206\u5927\u5c0f\u5199&#xff09;\u3002<\/p>\n<p> String s1 &#061; &#034;hello&#034;;<br \/>\nString s2 &#061; &#034;Hello&#034;;<br \/>\nSystem.out.println(s1.equalsIgnoreCase(s2)); \/\/ \u8f93\u51fa&#xff1a;true\n <\/li>\n<li>\n<p>compareTo(String str) \u6309\u5b57\u5178\u987a\u5e8f\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32&#xff08;\u8fd4\u56de\u6574\u6570&#xff1a;\u6b63\u6570\u8868\u793a\u5f53\u524d\u5b57\u7b26\u4e32\u66f4\u5927&#xff0c;\u8d1f\u6570\u8868\u793a\u66f4\u5c0f&#xff0c;0 \u8868\u793a\u76f8\u7b49&#xff09;\u3002<\/p>\n<p> String s1 &#061; &#034;apple&#034;;<br \/>\nString s2 &#061; &#034;banana&#034;;<br \/>\nSystem.out.println(s1.compareTo(s2)); \/\/ \u8f93\u51fa&#xff1a;\u8d1f\u6570&#xff08;&#039;a&#039; &lt; &#039;b&#039;&#xff09;\n <\/li>\n<h4>\u4e09\u3001\u5b57\u7b26\u4e32\u4fee\u6539&#xff08;\u8fd4\u56de\u65b0\u5b57\u7b26\u4e32&#xff0c;\u539f\u5b57\u7b26\u4e32\u4e0d\u53d8&#xff09;<\/h4>\n<li>\n<p>concat(String str) \u5c06\u5f53\u524d\u5b57\u7b26\u4e32\u4e0e\u00a0str\u00a0\u62fc\u63a5&#xff0c;\u8fd4\u56de\u65b0\u5b57\u7b26\u4e32&#xff08;\u7b49\u6548\u4e8e\u00a0&#043;\u00a0\u8fd0\u7b97\u7b26&#xff09;\u3002<\/p>\n<p> String s &#061; &#034;hello&#034;.concat(&#034; world&#034;);<br \/>\nSystem.out.println(s); \/\/ \u8f93\u51fa&#xff1a;&#034;hello world&#034;\n <\/li>\n<li>\n<p>substring(int beginIndex) \u4ece\u00a0<font face=\"monospace\">beginIndex<\/font>\u5f00\u59cb\u622a\u53d6\u5b50\u5b57\u7b26\u4e32&#xff0c;\u76f4\u5230\u672b\u5c3e\u3002<\/p>\n<p> String s &#061; &#034;hello world&#034;;<br \/>\nSystem.out.println(s.substring(6)); \/\/ \u8f93\u51fa&#xff1a;&#034;world&#034;\n <\/li>\n<li>\n<p>substring(int beginIndex, int endIndex) \u622a\u53d6\u00a0[beginIndex, endIndex)\u00a0\u8303\u56f4\u5185\u7684\u5b50\u5b57\u7b26\u4e32&#xff08;\u5305\u542b\u5f00\u59cb&#xff0c;\u4e0d\u5305\u542b\u7ed3\u675f&#xff09;\u3002<\/p>\n<p> String s &#061; &#034;hello world&#034;;<br \/>\nSystem.out.println(s.substring(0, 5)); \/\/ \u8f93\u51fa&#xff1a;&#034;hello&#034;\n <\/li>\n<li>\n<p>toLowerCase()\u00a0\/\u00a0toUpperCase() \u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5168\u5c0f\u5199 \/ \u5168\u5927\u5199&#xff0c;\u8fd4\u56de\u65b0\u5b57\u7b26\u4e32\u3002<\/p>\n<p> String s &#061; &#034;Hello World&#034;;<br \/>\nSystem.out.println(s.toLowerCase()); \/\/ \u8f93\u51fa&#xff1a;&#034;hello world&#034;<br \/>\nSystem.out.println(s.toUpperCase()); \/\/ \u8f93\u51fa&#xff1a;&#034;HELLO WORLD&#034;\n <\/li>\n<li>\n<p>trim() \u53bb\u9664\u5b57\u7b26\u4e32\u9996\u5c3e\u7684\u7a7a\u767d\u5b57\u7b26&#xff08;\u7a7a\u683c\u3001\u6362\u884c\u3001\u5236\u8868\u7b26\u7b49&#xff09;&#xff0c;\u8fd4\u56de\u65b0\u5b57\u7b26\u4e32\u3002<\/p>\n<p> String s &#061; &#034;  hello  &#034;;<br \/>\nSystem.out.println(s.trim()); \/\/ \u8f93\u51fa&#xff1a;&#034;hello&#034;\n <\/li>\n<li>\n<p>replace(char oldChar, char newChar) \u5c06\u5b57\u7b26\u4e32\u4e2d\u6240\u6709\u00a0oldChar\u00a0\u66ff\u6362\u4e3a\u00a0newChar&#xff0c;\u8fd4\u56de\u65b0\u5b57\u7b26\u4e32\u3002<\/p>\n<p> String s &#061; &#034;hello&#034;;<br \/>\nSystem.out.println(s.replace(&#039;l&#039;, &#039;x&#039;)); \/\/ \u8f93\u51fa&#xff1a;&#034;hexxo&#034;\n <\/li>\n<li>\n<p>replace(CharSequence target, CharSequence replacement) \u66ff\u6362\u6240\u6709\u5339\u914d\u7684\u5b50\u5b57\u7b26\u4e32\u00a0target\u00a0\u4e3a\u00a0replacement\u3002<\/p>\n<p> String s &#061; &#034;hello world&#034;;<br \/>\nSystem.out.println(s.replace(&#034;world&#034;, &#034;java&#034;)); \/\/ \u8f93\u51fa&#xff1a;&#034;hello java&#034;\n <\/li>\n<h4>\u56db\u3001\u5176\u4ed6\u5e38\u7528\u65b9\u6cd5<\/h4>\n<li>\n<p>split(String regex) \u6839\u636e\u6b63\u5219\u8868\u8fbe\u5f0f\u00a0regex\u00a0\u5206\u5272\u5b57\u7b26\u4e32&#xff0c;\u8fd4\u56de\u5b57\u7b26\u4e32\u6570\u7ec4\u3002<\/p>\n<p> String s &#061; &#034;apple,banana,orange&#034;;<br \/>\nString[] parts &#061; s.split(&#034;,&#034;); \/\/ \u6309\u9017\u53f7\u5206\u5272<br \/>\n\/\/ parts \u7ed3\u679c&#xff1a;[&#034;apple&#034;, &#034;banana&#034;, &#034;orange&#034;]\n <\/li>\n<li>\n<p>startsWith(String prefix) \u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4ee5\u00a0prefix\u00a0\u5f00\u5934&#xff08;\u8fd4\u56de\u00a0boolean&#xff09;\u3002<\/p>\n<p> String s &#061; &#034;hello world&#034;;<br \/>\nSystem.out.println(s.startsWith(&#034;hello&#034;)); \/\/ \u8f93\u51fa&#xff1a;true\n <\/li>\n<li>\n<p>endsWith(String suffix) \u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4ee5\u00a0suffix\u00a0\u7ed3\u5c3e&#xff08;\u8fd4\u56de\u00a0boolean&#xff09;\u3002<\/p>\n<p> String s &#061; &#034;hello world&#034;;<br \/>\nSystem.out.println(s.endsWith(&#034;world&#034;)); \/\/ \u8f93\u51fa&#xff1a;true\n <\/li>\n<li>\n<p>isEmpty() \u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a&#xff08;\u957f\u5ea6\u4e3a 0&#xff0c;\u8fd4\u56de\u00a0boolean&#xff09;\u3002<\/p>\n<p> String s &#061; &#034;&#034;;<br \/>\nSystem.out.println(s.isEmpty()); \/\/ \u8f93\u51fa&#xff1a;true\n <\/li>\n<li>\n<p>valueOf(&#8230;)&#xff08;\u9759\u6001\u65b9\u6cd5&#xff09; \u5c06\u5176\u4ed6\u7c7b\u578b&#xff08;\u5982\u00a0int\u3001double\u3001Object\u00a0\u7b49&#xff09;\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002<\/p>\n<p> String s1 &#061; String.valueOf(123); \/\/ &#034;123&#034;<br \/>\nString s2 &#061; String.valueOf(true); \/\/ &#034;true&#034; <\/li>\n<h2><\/h2>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb141\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Java\u4e2dString\u7c7b\u7684\u7279\u6027\u4e0e\u5e38\u7528\u65b9\u6cd5\u3002\u4e0eC\u8bed\u8a00\u4e0d\u540c\uff0cJava\u901a\u8fc7String\u7c7b\u5b58\u50a8\u5b57\u7b26\u4e32\uff0c\u5177\u6709\u4e0d\u53ef\u53d8\u6027\uff0c\u4fee\u6539\u64cd\u4f5c\u4f1a\u521b\u5efa\u65b0\u5bf9\u8c61\u800c\u975e\u6539\u53d8\u539f\u5b57\u7b26\u4e32\u3002\u6587\u7ae0\u8be6\u7ec6\u8bf4\u660e\u4e86\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\u673a\u5236\uff0c\u89e3\u91ca\u4e86&quot;==&quot;\u548cequals()\u7684\u533a\u522b\uff0c\u5e76\u901a\u8fc7\u793a\u4f8b\u5c55\u793a\u4e86\u5b57\u7b26\u4e32\u6bd4\u8f83\u3001\u62fc\u63a5\u3001\u622a\u53d6\u3001\u66ff\u6362\u7b49\u64cd\u4f5c\u3002\u6b64\u5916\uff0c\u8fd8\u4ecb\u7ecd\u4e86length()\u3001charAt()\u3001indexOf()\u7b49\u83b7\u53d6\u5b57\u7b26\u4e32\u4fe1\u606f\u7684\u65b9\u6cd5\uff0c\u4ee5\u53casplit()\u3001startsWith()\u7b49\u5b9e\u7528\u529f\u80fd\u3002\u91cd\u70b9\u5f3a\u8c03\u4e86String\u7c7b\u7684\u4e0d\u53ef\u53d8\u6027\u548c\u5e38\u91cf\u6c60\u7684\u5185\u5b58\u590d\u7528\u4f18\u52bf\u3002<\/p>\n","protected":false},"author":2,"featured_media":52188,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1874,99,190],"topic":[],"class_list":{"0":"post-52191","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-server","8":"tag-java","10":"tag-190"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>String\u7c7b\u7684\u5b58\u50a8\u7ed3\u6784\u4e0e\u5e38\u7528\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/52191.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"String\u7c7b\u7684\u5b58\u50a8\u7ed3\u6784\u4e0e\u5e38\u7528\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb141\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Java\u4e2dString\u7c7b\u7684\u7279\u6027\u4e0e\u5e38\u7528\u65b9\u6cd5\u3002\u4e0eC\u8bed\u8a00\u4e0d\u540c\uff0cJava\u901a\u8fc7String\u7c7b\u5b58\u50a8\u5b57\u7b26\u4e32\uff0c\u5177\u6709\u4e0d\u53ef\u53d8\u6027\uff0c\u4fee\u6539\u64cd\u4f5c\u4f1a\u521b\u5efa\u65b0\u5bf9\u8c61\u800c\u975e\u6539\u53d8\u539f\u5b57\u7b26\u4e32\u3002\u6587\u7ae0\u8be6\u7ec6\u8bf4\u660e\u4e86\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\u673a\u5236\uff0c\u89e3\u91ca\u4e86&quot;==&quot;\u548cequals()\u7684\u533a\u522b\uff0c\u5e76\u901a\u8fc7\u793a\u4f8b\u5c55\u793a\u4e86\u5b57\u7b26\u4e32\u6bd4\u8f83\u3001\u62fc\u63a5\u3001\u622a\u53d6\u3001\u66ff\u6362\u7b49\u64cd\u4f5c\u3002\u6b64\u5916\uff0c\u8fd8\u4ecb\u7ecd\u4e86length()\u3001charAt()\u3001indexOf()\u7b49\u83b7\u53d6\u5b57\u7b26\u4e32\u4fe1\u606f\u7684\u65b9\u6cd5\uff0c\u4ee5\u53casplit()\u3001startsWith()\u7b49\u5b9e\u7528\u529f\u80fd\u3002\u91cd\u70b9\u5f3a\u8c03\u4e86String\u7c7b\u7684\u4e0d\u53ef\u53d8\u6027\u548c\u5e38\u91cf\u6c60\u7684\u5185\u5b58\u590d\u7528\u4f18\u52bf\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/52191.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-11T03:14:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811031417-68996009954c7.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52191.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/52191.html\",\"name\":\"String\u7c7b\u7684\u5b58\u50a8\u7ed3\u6784\u4e0e\u5e38\u7528\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-11T03:14:21+00:00\",\"dateModified\":\"2025-08-11T03:14:21+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/52191.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/52191.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52191.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"String\u7c7b\u7684\u5b58\u50a8\u7ed3\u6784\u4e0e\u5e38\u7528\u65b9\u6cd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"String\u7c7b\u7684\u5b58\u50a8\u7ed3\u6784\u4e0e\u5e38\u7528\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/52191.html","og_locale":"zh_CN","og_type":"article","og_title":"String\u7c7b\u7684\u5b58\u50a8\u7ed3\u6784\u4e0e\u5e38\u7528\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb141\u6b21\uff0c\u70b9\u8d5e6\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86Java\u4e2dString\u7c7b\u7684\u7279\u6027\u4e0e\u5e38\u7528\u65b9\u6cd5\u3002\u4e0eC\u8bed\u8a00\u4e0d\u540c\uff0cJava\u901a\u8fc7String\u7c7b\u5b58\u50a8\u5b57\u7b26\u4e32\uff0c\u5177\u6709\u4e0d\u53ef\u53d8\u6027\uff0c\u4fee\u6539\u64cd\u4f5c\u4f1a\u521b\u5efa\u65b0\u5bf9\u8c61\u800c\u975e\u6539\u53d8\u539f\u5b57\u7b26\u4e32\u3002\u6587\u7ae0\u8be6\u7ec6\u8bf4\u660e\u4e86\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\u673a\u5236\uff0c\u89e3\u91ca\u4e86&quot;==&quot;\u548cequals()\u7684\u533a\u522b\uff0c\u5e76\u901a\u8fc7\u793a\u4f8b\u5c55\u793a\u4e86\u5b57\u7b26\u4e32\u6bd4\u8f83\u3001\u62fc\u63a5\u3001\u622a\u53d6\u3001\u66ff\u6362\u7b49\u64cd\u4f5c\u3002\u6b64\u5916\uff0c\u8fd8\u4ecb\u7ecd\u4e86length()\u3001charAt()\u3001indexOf()\u7b49\u83b7\u53d6\u5b57\u7b26\u4e32\u4fe1\u606f\u7684\u65b9\u6cd5\uff0c\u4ee5\u53casplit()\u3001startsWith()\u7b49\u5b9e\u7528\u529f\u80fd\u3002\u91cd\u70b9\u5f3a\u8c03\u4e86String\u7c7b\u7684\u4e0d\u53ef\u53d8\u6027\u548c\u5e38\u91cf\u6c60\u7684\u5185\u5b58\u590d\u7528\u4f18\u52bf\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/52191.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-11T03:14:21+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250811031417-68996009954c7.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/52191.html","url":"https:\/\/www.wsisp.com\/helps\/52191.html","name":"String\u7c7b\u7684\u5b58\u50a8\u7ed3\u6784\u4e0e\u5e38\u7528\u65b9\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-11T03:14:21+00:00","dateModified":"2025-08-11T03:14:21+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/52191.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/52191.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/52191.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"String\u7c7b\u7684\u5b58\u50a8\u7ed3\u6784\u4e0e\u5e38\u7528\u65b9\u6cd5"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=52191"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52191\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/52188"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=52191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=52191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=52191"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=52191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}