{"id":54,"date":"2015-03-30T09:18:47","date_gmt":"2015-03-30T01:18:47","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=54"},"modified":"2026-08-18T10:37:18","modified_gmt":"2026-08-18T02:37:18","slug":"java%e5%ad%97%e7%ac%a6%e4%b8%b2string","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=54","title":{"rendered":"Java\u5b57\u7b26\u4e32(String)"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<p style=\"margin: 1em 0px;\">\u4ece\u8868\u9762\u4e0a\u770b\uff0c\u5b57\u7b26\u4e32\u5c31\u662f\u53cc\u5f15\u53f7\u4e4b\u95f4\u7684\u6570\u636e\uff0c\u4f8b\u5982\u300c\u6781\u5ba2\u4e4b\u5bb6\u300d\u3001\u300chttps:\/\/ai.zhousir.top\u300d\u3002\u5199\u8d77\u6765\u50cf <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">int<\/code>\u3001<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">float<\/code> \u4e00\u6837\u65b9\u4fbf\uff0c\u4f46\u5b83\u5176\u5b9e\u662f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">java.lang.String<\/code> \u7c7b\u7684\u5bf9\u8c61\u3002<\/p>\n<p><!--more--><\/p>\n<p style=\"margin: 1em 0px;\">\u628a String \u7528\u660e\u767d\uff0c\u5173\u952e\u5c31\u4e24\u4ef6\u4e8b\uff1a<strong style=\"color: #4870ac;\">\u600e\u4e48\u58f0\u660e<\/strong>\uff0c\u4ee5\u53ca\u4e3a\u4ec0\u4e48\u300c\u6539\u4e00\u4e2a\u5b57\u7b26\u4e32\u300d\u5176\u5b9e\u662f\u5728\u5f97\u5230\u4e00\u4e2a<strong style=\"color: #4870ac;\">\u65b0\u5bf9\u8c61<\/strong>\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e00\u3001\u600e\u4e48\u58f0\u660e\u4e00\u4e2a\u5b57\u7b26\u4e32<\/h2>\n<p style=\"margin: 1em 0px;\">\u6700\u5e38\u89c1\u7684\u5199\u6cd5\u662f\u5b57\u9762\u91cf\u3002\u56e0\u4e3a String \u592a\u5e38\u7528\uff0cJava \u4e3a\u5b83\u63d0\u4f9b\u4e86\u7b80\u5316\u8bed\u6cd5\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">String stringName = \"string content\";\nString url = \"https:\/\/ai.zhousir.top\";\nString webName = \"\u6781\u5ba2\u4e4b\u5bb6\";<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u6309\u6807\u51c6\u7684\u9762\u5411\u5bf9\u8c61\u5199\u6cd5\uff0c\u5e94\u5f53\u662f\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">String stringName = new String(\"string content\");\nString url = new String(\"https:\/\/ai.zhousir.top\");<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4e4b\u6240\u4ee5\u63d0\u4f9b\u7b80\u5316\u8bed\u6cd5\uff0c\u4e0d\u53ea\u662f\u56fe\u7701\u4e8b\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">new String(\"abc\")<\/code> \u5b9e\u9645\u4e0a\u4f1a\u6d89\u53ca<strong style=\"color: #4870ac;\">\u4e24\u4e2a\u5bf9\u8c61<\/strong>\uff1a\u4e00\u4e2a\u662f\u5e38\u91cf\u6c60\u91cc\u7684 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\"abc\"<\/code>\uff0c\u4e00\u4e2a\u662f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">new<\/code> \u5728\u5806\u4e0a\u65b0\u7533\u8bf7\u7684 String\u3002\u5b57\u9762\u91cf\u5199\u6cd5\u76f4\u63a5\u590d\u7528\u5e38\u91cf\u6c60\uff0c\u5c11\u4e00\u6b21\u6d6a\u8d39\u3002<\/p>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u5199\u6cd5<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u53d1\u751f\u4e86\u4ec0\u4e48<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u4ec0\u4e48\u65f6\u5019\u7528<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5b57\u9762\u91cf &#8220;abc&#8221;<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u4f18\u5148\u8d70\u5b57\u7b26\u4e32\u5e38\u91cf\u6c60\uff0c\u76f8\u540c\u5b57\u9762\u91cf\u53ef\u5171\u7528<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u65e5\u5e38\u58f0\u660e\uff0c\u9ed8\u8ba4\u7528\u8fd9\u4e2a<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">new String(&#8220;abc&#8221;)<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5e38\u91cf\u6c60\u4e00\u4efd\uff0c\u5806\u4e0a\u518d new \u4e00\u4efd<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u51e0\u4e4e\u4e0d\u9700\u8981\uff0c\u7406\u89e3\u5373\u53ef<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e8c\u3001\u7528 + \u62fc\u63a5<\/h2>\n<p style=\"margin: 1em 0px;\">\u5b57\u7b26\u4e32\u53ef\u4ee5\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">+<\/code> \u8fde\u63a5\u3002\u57fa\u672c\u7c7b\u578b\u548c\u5b57\u7b26\u4e32\u505a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">+<\/code>\uff0c\u4e00\u822c\u4e5f\u4f1a<strong style=\"color: #4870ac;\">\u81ea\u52a8\u8f6c\u6210\u5b57\u7b26\u4e32<\/strong>\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public class Demo {\n    public static void main(String[] args) {\n        String stuName = \"\u5c0f\u660e\";\n        int stuAge = 17;\n        float stuScore = 92.5f;\n\n        String info = stuName + \"\u7684\u5e74\u9f84\u662f \" + stuAge + \"\uff0c\u6210\u7ee9\u662f \" + stuScore;\n        System.out.println(info);\n    }\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\u5c0f\u660e\u7684\u5e74\u9f84\u662f 17\uff0c\u6210\u7ee9\u662f 92.5<\/code><\/pre>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e09\u3001\u4e0d\u53ef\u53d8\uff1a\u770b\u8d77\u6765\u50cf\u4fee\u6539\uff0c\u5176\u5b9e\u662f\u6362\u65b0\u5bf9\u8c61<\/h2>\n<p style=\"margin: 1em 0px;\">String \u548c\u6570\u7ec4\u6709\u4e00\u4e2a\u5171\u540c\u70b9\uff1a<strong style=\"color: #4870ac;\">\u521d\u59cb\u5316\u4e4b\u540e\uff0c\u957f\u5ea6\u4e0d\u53d8\uff0c\u5185\u5bb9\u4e5f\u4e0d\u53d8<\/strong>\u3002\u4f60\u4ee5\u4e3a\u5728\u6539\u5b83\uff0c\u5176\u5b9e\u662f\u5728\u4ea7\u751f\u4e00\u4e2a\u65b0\u5b57\u7b26\u4e32\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">String str = \"Hello \";\nstr += \"World!\";<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u770b\u8d77\u6765\u50cf\u63a5\u9f99\uff0c\u5728 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">str<\/code> \u540e\u9762\u63a5\u4e0a\u300cWorld!\u300d\uff0c\u5f97\u5230\u300cHello World!\u300d\u3002\u5b9e\u9645\u8fc7\u7a0b\u662f\uff1a\u5148\u6709\u300cHello \u300d\u5360\u7740\u4e00\u5757\u5185\u5b58\uff1b\u5b57\u7b26\u4e32\u4e00\u65e6\u521d\u59cb\u5316\uff0c\u8fd9\u5757\u7a7a\u95f4\u7684\u957f\u5ea6\u5c31\u662f\u56fa\u5b9a\u7684\uff0c\u6ca1\u6cd5\u539f\u5730\u8ffd\u52a0\u3002\u8981\u53d8\uff0c\u53ea\u80fd<strong style=\"color: #4870ac;\">\u653e\u5f03\u539f\u6765\u7684\u5bf9\u8c61<\/strong>\uff0c\u91cd\u65b0\u7533\u8bf7\u80fd\u653e\u4e0b\u300cHello World!\u300d\u7684\u7a7a\u95f4\uff0c\u518d\u628a\u65b0\u5185\u5bb9\u653e\u8fdb\u53bb\u3002\u53d8\u91cf <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">str<\/code> \u53ea\u662f\u6539\u53bb\u6307\u5411\u8fd9\u4e2a\u65b0\u5bf9\u8c61\u3002<\/p>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u770b\u8d77\u6765\u50cf<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u5b9e\u9645\u53d1\u751f\u4e86\u4ec0\u4e48<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">str += &#8220;World!&#8221;<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u521b\u5efa\u65b0 String\uff0cstr \u6539\u6307\u5411\u65b0\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">replace(&#8230;)<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u8fd4\u56de\u65b0\u5b57\u7b26\u4e32\uff0c\u539f\u4e32\u539f\u5c01\u4e0d\u52a8<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5faa\u73af\u91cc\u53cd\u590d\u7528 + \u62fc\u63a5<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6bcf\u6b21\u90fd new\uff0c\u5bf9\u8c61\u591a\u3001\u4e5f\u6162<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin: 1em 0px;\">\u5faa\u73af\u91cc\u5927\u91cf\u62fc\u63a5\u65f6\uff0c\u66f4\u5408\u9002\u7684\u5de5\u5177\u662f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">StringBuilder<\/code>\uff0c\u4e0d\u8981\u7528 String \u4e00\u6b21\u6b21 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">+<\/code>\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u56db\u3001\u5e38\u7528\u65b9\u6cd5\u901f\u67e5<\/h2>\n<p style=\"margin: 1em 0px;\">String \u5bf9\u8c61\u6709\u5f88\u591a\u65b9\u6cd5\uff0c\u4e0b\u9762\u51e0\u4e2a\u6700\u5e38\u7528\u3002\u65e0\u8bba\u5b57\u6bcd\u3001\u6570\u5b57\u8fd8\u662f\u6c49\u5b57\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">length()<\/code> \u91cc<strong style=\"color: #4870ac;\">\u6bcf\u4e2a\u5b57\u7b26\u7684\u957f\u5ea6\u90fd\u662f 1<\/strong>\u3002<\/p>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u65b9\u6cd5<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u4f5c\u7528<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u6ce8\u610f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">length()<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u8fd4\u56de\u5b57\u7b26\u4e32\u957f\u5ea6<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6c49\u5b57\u3001\u5b57\u6bcd\u3001\u6570\u5b57\u90fd\u6309 1 \u4e2a\u5b57\u7b26\u8ba1<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">charAt(i)<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6309\u7d22\u5f15\u53d6\u5b57\u7b26<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u7b2c\u4e00\u4e2a\u5b57\u7b26\u7d22\u5f15\u662f 0<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">contains(s)<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u662f\u5426\u5305\u542b\u67d0\u4e2a\u5b50\u4e32<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u8fd4\u56de true \/ false<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">replace(old, new)<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u66ff\u6362\u6240\u6709\u6307\u5b9a\u5b50\u4e32<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u4e0d\u6539\u539f\u4e32\uff0c\u8fd4\u56de\u65b0\u4e32<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">split(sep)<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6309\u5206\u9694\u7b26\u5207\u6210\u6570\u7ec4<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u7ed3\u679c\u662f String[]<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">1\uff09length()<\/h3>\n<p style=\"margin: 1em 0px;\">\u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">String str1 = \"\u65b0\u534e\u82d1\";\nString str2 = \"scxh\";\nSystem.out.println(\"The length of str1 is \" + str1.length());\nSystem.out.println(\"The length of str2 is \" + str2.length());<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">The length of str1 is 3\nThe length of str2 is 4<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">2\uff09charAt()<\/h3>\n<p style=\"margin: 1em 0px;\">\u6309\u7d22\u5f15\u53d6\u51fa\u6307\u5b9a\u5b57\u7b26\u3002Java \u89c4\u5b9a\uff1a\u7b2c\u4e00\u4e2a\u5b57\u7b26\u7684\u7d22\u5f15\u662f 0\uff0c\u7b2c\u4e8c\u4e2a\u662f 1\uff0c\u4f9d\u6b21\u7c7b\u63a8\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">String str = \"123456789\";\nSystem.out.println(str.charAt(0) + \"    \" + str.charAt(5) + \"    \" + str.charAt(8));<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">1    6    9<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">3\uff09contains()<\/h3>\n<p style=\"margin: 1em 0px;\">\u68c0\u6d4b\u5b57\u7b26\u4e32\u662f\u5426\u5305\u542b\u67d0\u4e2a\u5b50\u4e32\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">String str = \"weixueyuan\";\nSystem.out.println(str.contains(\"yuan\"));\nSystem.out.println(str.contains(\"abc\"));<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">true\nfalse<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">4\uff09replace()<\/h3>\n<p style=\"margin: 1em 0px;\">\u66ff\u6362\u5b57\u7b26\u4e32\u4e2d\u6240\u6709\u6307\u5b9a\u7684\u5b50\u4e32\u3002<strong style=\"color: #4870ac;\">replace() \u4e0d\u4f1a\u6539\u53d8\u539f\u6765\u7684\u5b57\u7b26\u4e32<\/strong>\uff0c\u800c\u662f\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">String str1 = \"The url of weixueyuan is www.warmtel.com!\";\nString str2 = str1.replace(\"warmtel\", \"\u65b0\u534e\u82d1\");\nSystem.out.println(str1);\nSystem.out.println(str2);<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">The url of weixueyuan is www.warmtel.com!\nThe url of weixueyuan is www.\u65b0\u534e\u82d1.com!<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">str1<\/code> \u6253\u5370\u51fa\u6765\u4ecd\u662f\u539f\u6587\uff0c\u53ea\u6709 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">str2<\/code> \u91cc\u7684 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">warmtel<\/code> \u88ab\u6362\u6210\u4e86\u300c\u65b0\u534e\u82d1\u300d\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">5\uff09split()<\/h3>\n<p style=\"margin: 1em 0px;\">\u4ee5\u6307\u5b9a\u5b57\u7b26\u4e32\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u628a\u5f53\u524d\u5b57\u7b26\u4e32\u5207\u6210\u6570\u7ec4\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">import java.util.*;\n\npublic class Demo {\n    public static void main(String[] args) {\n        String str = \"wei_xue_yuan_is_good\";\n        String[] strArr = str.split(\"_\");\n        System.out.println(Arrays.toString(strArr));\n    }\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">[wei, xue, yuan, is, good]<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4ee5\u4e0a\u53ea\u5217\u4e3e\u4e86\u51e0\u4e2a\u5e38\u7528\u65b9\u6cd5\uff0c\u66f4\u591a\u65b9\u6cd5\u548c\u8be6\u7ec6\u89e3\u91ca\u8bf7\u53c2\u8003 JDK \u7684 API \u6587\u6863\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e94\u3001\u53c2\u8003\u4e0e\u6536\u5c3e<\/h2>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u65e5\u5e38\u58f0\u660e\u7528\u5b57\u9762\u91cf\uff0c\u4e0d\u5fc5 new String\u3002<\/section>\n<\/li>\n<li>\n<section>String \u4e0d\u53ef\u53d8\uff1a+\u3001+=\u3001replace \u90fd\u662f\u5f97\u5230\u65b0\u5bf9\u8c61\u3002<\/section>\n<\/li>\n<li>\n<section>\u5faa\u73af\u91cc\u5927\u91cf\u62fc\u63a5\uff0c\u6539\u7528 StringBuilder\u3002<\/section>\n<\/li>\n<\/ul>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1aString \u662f\u4e0d\u53ef\u53d8\u7684\u7c7b\u3002\u5b57\u9762\u91cf\u8d70\u5e38\u91cf\u6c60\uff0c+ \/ replace \/ += \u770b\u8d77\u6765\u50cf\u5728\u6539\uff0c\u5176\u5b9e\u90fd\u5728\u5f97\u5230\u65b0\u5bf9\u8c61\u3002\u628a\u8fd9\u4ef6\u4e8b\u8bb0\u4f4f\uff0c\u5e38\u7528 API \u7528\u8d77\u6765\u624d\u4e0d\u4f1a\u8e29\u5751\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u8868\u9762\u4e0a\u770b\uff0c\u5b57\u7b26\u4e32\u5c31\u662f\u53cc\u5f15\u53f7\u4e4b\u95f4\u7684\u6570\u636e\uff0c\u4f8b\u5982\u300c\u6781\u5ba2\u4e4b\u5bb6\u300d\u3001\u300chttps:\/\/ai.zhousir.top\u300d\u3002\u5199 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[29,30],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/54"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=54"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":3839,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/54\/revisions\/3839"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}