{"id":276751,"date":"2024-05-16T15:02:18","date_gmt":"2024-05-16T07:02:18","guid":{"rendered":""},"modified":"2024-05-16T15:02:25","modified_gmt":"2024-05-16T07:02:25","slug":"java-%e9%a1%b9%e7%9b%ae%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%b8%b8%e7%94%a8%e6%96%b9%e6%b3%95%e6%9c%89%e5%93%aa%e4%ba%9b","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/276751.html","title":{"rendered":"java \u9879\u76ee\u5b57\u7b26\u4e32\u5e38\u7528\u65b9\u6cd5\u6709\u54ea\u4e9b"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24201102\/d589f23c-d06e-477b-90d7-c3830b6623c7.webp\" alt=\"java \u9879\u76ee\u5b57\u7b26\u4e32\u5e38\u7528\u65b9\u6cd5\u6709\u54ea\u4e9b\" \/><\/p>\n<p><p><strong>Java \u9879\u76ee\u4e2d\u5b57\u7b26\u4e32\u5e38\u7528\u7684\u65b9\u6cd5\u5305\u62ec<code>length()<\/code>\u3001<code>charAt()<\/code>\u3001<code>substring()<\/code>\u3001<code>indexOf()<\/code>\u3001<code>lastIndexOf()<\/code>\u3001<code>concat()<\/code>\u3001<code>replace()<\/code>\u3001<code>replaceAll()<\/code>\u3001<code>split()<\/code>\u3001<code>toUpperCase()<\/code>\u3001<code>toLowerCase()<\/code>\u4ee5\u53ca<code>trim()<\/code>\u3002<\/strong> \u5176\u4e2d\uff0c<code>substring()<\/code> \u662f\u5728\u7528\u4e8e\u83b7\u53d6\u5b57\u7b26\u4e32\u7684\u4e00\u90e8\u5206\uff0c\u975e\u5e38\u5b9e\u7528\u3002\u6b64\u65b9\u6cd5\u63a5\u53d7\u4e00\u4e2a\u6216\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u5f00\u59cb\u7d22\u5f15\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u7ed3\u675f\u7d22\u5f15\uff08\u53ef\u9009\uff09\u3002\u5982\u679c\u53ea\u63d0\u4f9b\u4e00\u4e2a\u53c2\u6570\uff0c\u5b83\u5c06\u8fd4\u56de\u4ece\u8be5\u7d22\u5f15\u5230\u5b57\u7b26\u4e32\u672b\u5c3e\u7684\u5b50\u5b57\u7b26\u4e32\u3002\u5982\u679c\u63d0\u4f9b\u4e24\u4e2a\u53c2\u6570\uff0c\u5b83\u4f1a\u8fd4\u56de\u4ece\u5f00\u59cb\u7d22\u5f15\u5230\u7ed3\u675f\u7d22\u5f15\uff08\u4f46\u4e0d\u5305\u62ec\u7ed3\u675f\u7d22\u5f15\uff09\u4e4b\u95f4\u7684\u5b50\u5b57\u7b26\u4e32\u3002\u8be5\u65b9\u6cd5\u5e38\u7528\u4e8e\u5904\u7406\u3001\u683c\u5f0f\u5316\u6216\u63d0\u53d6\u6587\u672c\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001LENGTH()\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p><strong><code>length()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u5feb\u901f\u83b7\u5f97\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\uff0c\u8fd9\u5728\u5904\u7406\u5b57\u7b26\u4e32\u65f6\u5c24\u4e3a\u91cd\u8981\u3002<\/strong> \u5b83\u4e0d\u9700\u8981\u4efb\u4f55\u53c2\u6570\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u7b26\u6570\u91cf\u3002\u56e0\u4e3aJava\u5b57\u7b26\u4e32\u662f\u7531\u5b57\u7b26\u6570\u7ec4\u5b9e\u73b0\u7684\uff0c\u6240\u4ee5\u8fd9\u4e2a\u65b9\u6cd5\u5b9e\u9645\u4e0a\u662f\u8fd4\u56de\u6570\u7ec4\u7684\u957f\u5ea6\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5982\u679c\u6211\u4eec\u9700\u8981\u68c0\u6d4b\u7528\u6237\u8f93\u5165\u7684\u5bc6\u7801\u7684\u957f\u5ea6\u662f\u5426\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>length()<\/code>\u65b9\u6cd5\u6765\u5b9e\u73b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-java\">String password = &quot;MySecretPassword!&quot;;<\/p>\n<p>int length = password.length();<\/p>\n<p>if(length &gt;= 8) {<\/p>\n<p>    System.out.println(&quot;\u5bc6\u7801\u957f\u5ea6\u7b26\u5408\u8981\u6c42\u3002&quot;);<\/p>\n<p>} else {<\/p>\n<p>    System.out.println(&quot;\u5bc6\u7801\u957f\u5ea6\u8fc7\u77ed\uff0c\u8bf7\u91cd\u65b0\u8bbe\u5b9a\uff01&quot;);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001CHARAT()\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p><strong><code>charAt()<\/code>\u65b9\u6cd5\u7528\u4e8e\u83b7\u53d6\u5b57\u7b26\u4e32\u4e2d\u6307\u5b9a\u7d22\u5f15\u4f4d\u7f6e\u7684\u5b57\u7b26\u3002<\/strong> \u5f53\u9700\u8981\u8bfb\u53d6\u3001\u5904\u7406\u6216\u8005\u9a8c\u8bc1\u5b57\u7b26\u4e32\u4e2d\u4e2a\u522b\u5b57\u7b26\u65f6\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u662f\u975e\u5e38\u6709\u7528\u7684\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-java\">String greeting = &quot;Hello, World!&quot;;<\/p>\n<p>char letter = greeting.charAt(7);<\/p>\n<p>System.out.println(&quot;\u5728\u7d22\u5f15\u4e3a7\u7684\u4f4d\u7f6e\u7684\u5b57\u7b26\u662f\uff1a&quot; + letter);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001SUBSTRING()\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p><strong><code>substring()<\/code>\u65b9\u6cd5\u7528\u4e8e\u4ece\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u3002<\/strong> \u5b83\u53ef\u4ee5\u63a5\u53d7\u4e00\u4e2a\u6216\u4e24\u4e2a\u53c2\u6570\uff0c\u4e00\u4e2a\u53c2\u6570\u65f6\u8868\u793a\u5b50\u4e32\u7684\u8d77\u59cb\u7d22\u5f15\uff0c\u4e24\u4e2a\u53c2\u6570\u65f6\u7b2c\u4e8c\u4e2a\u8868\u793a\u7ed3\u675f\u7d22\u5f15\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-java\">String sentence = &quot;Welcome to Java Programming!&quot;;<\/p>\n<p>String word = sentence.substring(11, 15);<\/p>\n<p>System.out.println(&quot;\u63d0\u53d6\u7684\u5355\u8bcd\u662f\uff1a&quot; + word);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001INDEXOF()\u548cLASTINDEXOF()\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p><strong><code>indexOf()<\/code>\u65b9\u6cd5\u8fd4\u56de\u6307\u5b9a\u5b57\u7b26\u6216\u5b50\u5b57\u7b26\u4e32\u5728\u5b57\u7b26\u4e32\u4e2d\u7b2c\u4e00\u6b21\u51fa\u73b0\u7684\u7d22\u5f15\uff0c\u5982\u679c\u6ca1\u6709\u627e\u5230\uff0c\u5219\u8fd4\u56de-1\u3002<\/strong> <code>lastIndexOf()<\/code>\u65b9\u6cd5\u5219\u8fd4\u56de\u5728\u5b57\u7b26\u4e32\u4e2d\u6700\u540e\u4e00\u6b21\u51fa\u73b0\u7684\u7d22\u5f15\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-java\">String document = &quot;The quick brown fox jumps over the lazy dog.&quot;;<\/p>\n<p>int firstIndex = document.indexOf(&#039;o&#039;);<\/p>\n<p>int lastIndex = document.lastIndexOf(&#039;o&#039;);<\/p>\n<p>System.out.println(&quot;\u5b57\u6bcd&#039;o&#039;\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\uff1a&quot; + firstIndex);<\/p>\n<p>System.out.println(&quot;\u5b57\u6bcd&#039;o&#039;\u6700\u540e\u51fa\u73b0\u7684\u4f4d\u7f6e\uff1a&quot; + lastIndex);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001CONCAT()\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p><strong><code>concat()<\/code>\u65b9\u6cd5\u7528\u6765\u8fde\u63a5\u4e24\u4e2a\u5b57\u7b26\u4e32\uff0c\u5b83\u7684\u529f\u80fd\u5b9e\u9645\u4e0a\u548c&quot;+&quot;\u64cd\u4f5c\u7b26\u975e\u5e38\u76f8\u4f3c\u3002<\/strong> \u4f7f\u7528<code>concat()<\/code>\u65b9\u6cd5\u901a\u5e38\u53ef\u4ee5\u4f7f\u4ee3\u7801\u66f4\u52a0\u6e05\u6670\u6613\u8bfb\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-java\">String firstName = &quot;John&quot;;<\/p>\n<p>String lastName = &quot;Doe&quot;;<\/p>\n<p>String fullName = firstName.concat(&quot; &quot;).concat(lastName);<\/p>\n<p>System.out.println(&quot;\u5b8c\u6574\u7684\u540d\u5b57\u662f\uff1a&quot; + fullName);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001REPLACE()\u548cREPLACEALL()\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p><strong><code>replace()<\/code>\u548c<code>replaceAll()<\/code>\u65b9\u6cd5\u7528\u4e8e\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u7b26\u6216\u5b50\u4e32\u3002<\/strong> <code>replace()<\/code>\u65b9\u6cd5\u66ff\u6362\u5b57\u7b26\u6216\u8005\u5b50\u4e32\uff0c\u800c<code>replaceAll()<\/code>\u65b9\u6cd5\u57fa\u4e8e\u6b63\u5219\u8868\u8fbe\u5f0f\u66ff\u6362\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-java\">String sentence = &quot;I use Java 8. I will upgrade to Java 9.&quot;;<\/p>\n<p>String updatedSentence = sentence.replace(&quot;Java 8&quot;, &quot;Java 11&quot;);<\/p>\n<p>System.out.println(&quot;\u66f4\u65b0\u540e\u7684\u53e5\u5b50\uff1a&quot; + updatedSentence);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001SPLIT()\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p><strong><code>split()<\/code>\u65b9\u6cd5\u6839\u636e\u63d0\u4f9b\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5c06\u5b57\u7b26\u4e32\u5206\u5272\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4\u3002<\/strong> \u8fd9\u5728\u6587\u672c\u5904\u7406\u65f6\u975e\u5e38\u6709\u7528\uff0c\u5c24\u5176\u662f\u5728\u5c06CSV\u3001\u65e5\u5fd7\u6587\u4ef6\u7b49\u683c\u5f0f\u5316\u6570\u636e\u8f6c\u6362\u4e3a\u5355\u72ec\u7684\u5143\u7d20\u65f6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-java\">String fruits = &quot;apple, banana, cherry, date&quot;;<\/p>\n<p>String[] fruitArray = fruits.split(&quot;, &quot;);<\/p>\n<p>for (String fruit : fruitArray) {<\/p>\n<p>    System.out.println(fruit);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001TOUPPERCASE()\u548cTOLOWERCASE()\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p><strong><code>toUpperCase()<\/code>\u548c<code>toLowerCase()<\/code>\u65b9\u6cd5\u7528\u4e8e\u8f6c\u6362\u5b57\u7b26\u4e32\u7684\u5927\u5c0f\u5199\u3002<\/strong> \u8fd9\u5728\u9700\u8981\u8fdb\u884c\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u7684\u6bd4\u8f83\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-java\">String input = &quot;Java Programming&quot;;<\/p>\n<p>String upperInput = input.toUpperCase();<\/p>\n<p>String lowerInput = input.toLowerCase();<\/p>\n<p>System.out.println(&quot;\u5927\u5199: &quot; + upperInput);<\/p>\n<p>System.out.println(&quot;\u5c0f\u5199: &quot; + lowerInput);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e5d\u3001TRIM()\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p><strong><code>trim()<\/code>\u65b9\u6cd5\u7528\u4e8e\u5220\u9664\u5b57\u7b26\u4e32\u5f00\u5934\u548c\u7ed3\u5c3e\u5904\u7684\u7a7a\u767d\u5b57\u7b26\u3002<\/strong> \u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u95f4\u6709\u7a7a\u767d\u5b57\u7b26\uff0c\u5b83\u4eec\u4e0d\u4f1a\u88ab\u79fb\u9664\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-java\">String userInput = &quot;   Java Programming!   &quot;;<\/p>\n<p>String trimmedInput = userInput.trim();<\/p>\n<p>System.out.println(&quot;\u539f\u59cb\u5b57\u7b26\u4e32\uff1a&quot; + userInput);<\/p>\n<p>System.out.println(&quot;\u53bb\u9664\u9996\u5c3e\u7a7a\u683c\u540e\u7684\u5b57\u7b26\u4e32\uff1a&quot; + trimmedInput);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u65b9\u6cd5\u6784\u6210\u4e86\u5b57\u7b26\u4e32\u5904\u7406\u7684\u57fa\u672c\u5de5\u5177\u96c6\uff0c\u5728\u65e5\u5e38Java\u5f00\u53d1\u4e2d\u975e\u5e38\u5b9e\u7528\u3002\u901a\u8fc7\u7ec4\u5408\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6784\u5efa\u51fa\u5904\u7406\u66f4\u590d\u6742\u6587\u672c\u64cd\u4f5c\u7684\u529f\u80fd\u3002\u5f53\u7136\uff0c\u9664\u4e86\u4e0a\u8ff0\u65b9\u6cd5\uff0c<code>String<\/code>\u7c7b\u8fd8\u5305\u542b\u8bb8\u591a\u5176\u4ed6\u6709\u7528\u7684\u65b9\u6cd5\u4f8b\u5982<code>startsWith()<\/code>\u3001<code>endsWith()<\/code>\u3001<code>matches()<\/code>\u3001<code>isEmpty()<\/code>\u7b49\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u5728\u4e0d\u540c\u7684\u60c5\u5883\u4e2d\u540c\u6837\u80fd\u591f\u53d1\u6325\u91cd\u8981\u4f5c\u7528\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u4ec0\u4e48\u662f\u5b57\u7b26\u4e32\u5e38\u7528\u65b9\u6cd5\uff0c\u5728Java\u9879\u76ee\u4e2d\u6709\u54ea\u4e9b\u5e38\u7528\u7684\u5b57\u7b26\u4e32\u65b9\u6cd5\uff1f<\/strong><\/p>\n<p>\u5b57\u7b26\u4e32\u5e38\u7528\u65b9\u6cd5\u662f\u6307\u5728Java\u9879\u76ee\u4e2d\u5e38\u7528\u7684\u64cd\u4f5c\u5b57\u7b26\u4e32\u7684\u65b9\u6cd5\uff0c\u7528\u4e8e\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u5904\u7406\u548c\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u5b57\u7b26\u4e32\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li><code>length()<\/code>\u65b9\u6cd5\uff1a\u7528\u4e8e\u83b7\u53d6\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\uff0c\u8fd4\u56de\u5b57\u7b26\u4e32\u4e2d\u5b57\u7b26\u7684\u4e2a\u6570\u3002<\/li>\n<li><code>charAt(int index)<\/code>\u65b9\u6cd5\uff1a\u7528\u4e8e\u83b7\u53d6\u6307\u5b9a\u4f4d\u7f6e\u7684\u5b57\u7b26\uff0cindex\u4e3a\u5b57\u7b26\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u7d22\u5f15\uff0c\u4ece0\u5f00\u59cb\u3002<\/li>\n<li><code>substring(int beginIndex, int endIndex)<\/code>\u65b9\u6cd5\uff1a\u7528\u4e8e\u622a\u53d6\u6307\u5b9a\u8303\u56f4\u5185\u7684\u5b50\u5b57\u7b26\u4e32\uff0cbeginIndex\u4e3a\u8d77\u59cb\u7d22\u5f15\uff08\u5305\u542b\uff09\uff0cendIndex\u4e3a\u7ed3\u675f\u7d22\u5f15\uff08\u4e0d\u5305\u542b\uff09\u3002<\/li>\n<li><code>concat(String str)<\/code>\u65b9\u6cd5\uff1a\u7528\u4e8e\u5c06\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u8fde\u63a5\u5230\u539f\u5b57\u7b26\u4e32\u7684\u672b\u5c3e\u3002<\/li>\n<li><code>equals(Object obj)<\/code>\u65b9\u6cd5\uff1a\u7528\u4e8e\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4e0e\u6307\u5b9a\u5bf9\u8c61\u76f8\u7b49\u3002<\/li>\n<li><code>indexOf(String str)<\/code>\u65b9\u6cd5\uff1a\u7528\u4e8e\u67e5\u627e\u6307\u5b9a\u5b57\u7b26\u4e32\u5728\u539f\u5b57\u7b26\u4e32\u4e2d\u7b2c\u4e00\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\u3002<\/li>\n<li><code>toUpperCase()<\/code>\u65b9\u6cd5\uff1a\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u5b57\u7b26\u8f6c\u6362\u4e3a\u5927\u5199\u3002<\/li>\n<li><code>toLowerCase()<\/code>\u65b9\u6cd5\uff1a\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u5b57\u7b26\u8f6c\u6362\u4e3a\u5c0f\u5199\u3002<\/li>\n<li><code>replace(char oldChar, char newChar)<\/code>\u65b9\u6cd5\uff1a\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u6307\u5b9a\u5b57\u7b26\u66ff\u6362\u4e3a\u65b0\u7684\u5b57\u7b26\u3002<\/li>\n<\/ul>\n<p><strong>2. \u5982\u4f55\u5728Java\u9879\u76ee\u4e2d\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\u6216\u8005\u4e3a\u7a7a\u683c\uff1f<\/strong><\/p>\n<p>\u5728Java\u9879\u76ee\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u6765\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\u6216\u8005\u4e3a\u7a7a\u683c\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528<code>isEmpty()<\/code>\u65b9\u6cd5\uff1a\u8be5\u65b9\u6cd5\u7528\u4e8e\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\uff0c\u5373\u957f\u5ea6\u4e3a0\u3002\u4f8b\u5982\uff1a<code>String str = &quot; &quot;; if (str.isEmpty()) {\/* \u5b57\u7b26\u4e32\u4e3a\u7a7a *\/}<\/code>\u3002<\/li>\n<li>\u4f7f\u7528<code>isBlank()<\/code>\u65b9\u6cd5\uff08Java 11\u53ca\u4ee5\u4e0a\u7248\u672c\uff09\uff1a\u8be5\u65b9\u6cd5\u7528\u4e8e\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\u6216\u8005\u53ea\u5305\u542b\u7a7a\u683c\u3002\u4f8b\u5982\uff1a<code>String str = &quot; &quot;; if (str.isBlank()) {\/* \u5b57\u7b26\u4e32\u4e3a\u7a7a\u6216\u8005\u53ea\u5305\u542b\u7a7a\u683c *\/}<\/code>\u3002<\/li>\n<\/ul>\n<p><strong>3. \u5728Java\u9879\u76ee\u4e2d\u5982\u4f55\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\uff0c\u5ffd\u7565\u5927\u5c0f\u5199\uff1f<\/strong><\/p>\n<p>\u5728Java\u9879\u76ee\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u6765\u6bd4\u8f83\u4e24\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\uff0c\u4e14\u5ffd\u7565\u5927\u5c0f\u5199\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528<code>equalsIgnoreCase(String anotherString)<\/code>\u65b9\u6cd5\uff1a\u8be5\u65b9\u6cd5\u7528\u4e8e\u5224\u65ad\u4e24\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\uff0c\u5ffd\u7565\u5927\u5c0f\u5199\u3002\u4f8b\u5982\uff1a<code>String str1 = &quot;hello&quot;; String str2 = &quot;HELLO&quot;; if (str1.equalsIgnoreCase(str2)) {\/* \u5b57\u7b26\u4e32\u76f8\u7b49\uff0c\u5ffd\u7565\u5927\u5c0f\u5199 *\/}<\/code>\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"Java \u9879\u76ee\u4e2d\u5b57\u7b26\u4e32\u5e38\u7528\u7684\u65b9\u6cd5\u5305\u62eclength()\u3001charAt()\u3001substring()\u3001indexOf [&hellip;]","protected":false},"author":3,"featured_media":276759,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/276751"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=276751"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/276751\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/276759"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=276751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=276751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=276751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}