{"id":65956,"date":"2025-05-03T11:16:08","date_gmt":"2025-05-03T03:16:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65956\/"},"modified":"2025-05-03T11:16:08","modified_gmt":"2025-05-03T03:16:08","slug":"java%e6%80%8e%e4%b9%88%e6%8a%8a%e6%95%b4%e6%95%b0%e8%bd%ac%e6%8d%a2%e4%b8%ba%e6%95%b0%e7%bb%84-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65956\/","title":{"rendered":"java\u600e\u4e48\u628a\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  \u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4\u7684\u65b9\u6cd5\u6709\uff1a\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u518d\u62c6\u5206\u4e3a\u5355\u4e2a\u5b57\u7b26\uff0c\u6700\u540e\u8f6c\u6362\u4e3a\u6570\u5b57\u6570\u7ec4\u3002\u4f7f\u7528\u53d6\u6a21\u8fd0\u7b97\u7b26\u5faa\u73af\u5206\u5272\u6574\u6570\uff0c\u6bcf\u6b21\u53d6\u4f59\u6570\u5e76\u6dfb\u52a0\u5230\u6570\u7ec4\u3002\u76f4\u63a5\u4f7f\u7528 array.of() \u65b9\u6cd5\u5c06\u6574\u6570\u5305\u88c5\u6210\u6570\u7ec4\uff08\u4ec5\u9002\u7528\u4e8e\u5355\u5143\u7d20\u6570\u7ec4\uff09\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/13\/2024111317095442051.jpg\" class=\"aligncenter\" title=\"java\u600e\u4e48\u628a\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4\u63d2\u56fe\" alt=\"java\u600e\u4e48\u628a\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4<\/strong><\/p>\n<p><strong>\u7b80\u4ecb<\/strong><\/p>\n<p>\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4\u662f\u4e00\u4e2a\u5c06\u5355\u4e2a\u6574\u6570\u503c\u5206\u89e3\u4e3a\u5176\u4e2a\u522b\u6570\u5b57\u7684\u8fc7\u7a0b\u3002\u8fd9\u5728\u9700\u8981\u5bf9\u6570\u5b57\u8fdb\u884c\u4e2a\u522b\u64cd\u4f5c\u6216\u63d0\u53d6\u7279\u5b9a\u6570\u5b57\u65f6\u5f88\u6709\u7528\u3002<\/p>\n<p><strong>\u65b9\u6cd5<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5728 Java \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528 String \u8f6c\u6362\uff1a<\/strong><\/p>\n<ul>\n<li>\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002<\/li>\n<li>\u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u4e3a\u5355\u4e2a\u5b57\u7b26\u7684\u6570\u7ec4\u3002<\/li>\n<li>\u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u6570\u5b57\u4ee5\u83b7\u53d6\u6570\u7ec4\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u53d6\u6a21\u8fd0\u7b97\u7b26\uff1a<\/strong><\/p>\n<ul>\n<li>\u5faa\u73af\u5206\u5272\u6574\u6570\uff0c\u76f4\u5230\u5f97\u5230 0\u3002<\/li>\n<li>\u6bcf\u6b21\u8fed\u4ee3\uff0c\u5c06\u6574\u6570\u9664\u4ee5 10 \u5e76\u5bf9\u4f59\u6570\u53d6\u6a21\u3002<\/li>\n<li>\u5c06\u4f59\u6570\u6dfb\u52a0\u5230\u6570\u7ec4\u4e2d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528 Array.of():<\/strong><\/p>\n<ul>\n<li>\u5bf9\u4e8e\u7b80\u5355\u7684\u5b9e\u73b0\uff0c\u53ef\u4ee5\u4f7f\u7528 Array.of() \u65b9\u6cd5\u5c06\u5355\u4e2a\u6574\u6570\u5305\u88c5\u4e3a\u6570\u7ec4\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p><strong>\u4f7f\u7528 String \u8f6c\u6362\uff1a<\/strong><\/p>\n<pre>int number = 123;\nString numberString = Integer.toString(number);\nchar[] numberArray = numberString.toCharArray();\nint[] result = new int[numberArray.length];\nfor (int i = 0; i &lt; numberArray.length; i++) {\n    result[i] = Integer.parseInt(numberArray[i] + \"\");\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u53d6\u6a21\u8fd0\u7b97\u7b26\uff1a<\/strong><\/p>\n<pre>int number = 123;\nint[] result = new int[10];\nint index = 0;\nwhile (number &gt; 0) {\n    int digit = number % 10;\n    result[index++] = digit;\n    number \/= 10;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528 Array.of():<\/strong><\/p>\n<pre>int number = 123;\nint[] result = Array.of(number);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u600e\u4e48\u628a\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4\u7684\u65b9\u6cd5\u6709\uff1a\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u518d\u62c6\u5206\u4e3a\u5355\u4e2a\u5b57\u7b26\uff0c\u6700\u540e\u8f6c\u6362\u4e3a\u6570\u5b57\u6570\u7ec4\u3002\u4f7f\u7528\u53d6\u6a21\u8fd0\u7b97\u7b26\u5faa\u73af\u5206\u5272\u6574\u6570\uff0c\u6bcf\u6b21\u53d6\u4f59\u6570\u5e76\u6dfb\u52a0\u5230\u6570\u7ec4\u3002\u76f4\u63a5\u4f7f\u7528 array.of() \u65b9\u6cd5\u5c06\u6574\u6570\u5305\u88c5\u6210\u6570\u7ec4\uff08\u4ec5\u9002\u7528\u4e8e\u5355\u5143\u7d20\u6570\u7ec4\uff09\u3002 \u5982\u4f55\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4 \u7b80\u4ecb \u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4\u662f\u4e00\u4e2a\u5c06\u5355\u4e2a\u6574\u6570\u503c\u5206\u89e3\u4e3a\u5176\u4e2a\u522b\u6570\u5b57\u7684\u8fc7\u7a0b\u3002\u8fd9\u5728\u9700\u8981\u5bf9\u6570\u5b57\u8fdb\u884c\u4e2a\u522b\u64cd\u4f5c\u6216\u63d0\u53d6\u7279\u5b9a\u6570\u5b57\u65f6\u5f88\u6709\u7528\u3002 \u65b9\u6cd5 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5728 Java \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u6570\u7ec4\uff1a \u4f7f\u7528 String \u8f6c\u6362\uff1a \u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002 \u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u4e3a\u5355\u4e2a\u5b57\u7b26\u7684\u6570\u7ec4\u3002 \u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u6570\u5b57\u4ee5\u83b7\u53d6\u6570\u7ec4\u3002 \u4f7f\u7528\u53d6\u6a21\u8fd0\u7b97\u7b26\uff1a \u5faa\u73af\u5206\u5272\u6574\u6570\uff0c\u76f4\u5230\u5f97\u5230 0\u3002 \u6bcf\u6b21\u8fed\u4ee3\uff0c\u5c06\u6574\u6570\u9664\u4ee5 10 \u5e76\u5bf9\u4f59\u6570\u53d6\u6a21\u3002 \u5c06\u4f59\u6570\u6dfb\u52a0\u5230\u6570\u7ec4\u4e2d\u3002 \u4f7f\u7528 Array.of(): \u5bf9\u4e8e\u7b80\u5355\u7684\u5b9e\u73b0\uff0c\u53ef\u4ee5\u4f7f\u7528 Array.of() \u65b9\u6cd5\u5c06\u5355\u4e2a\u6574\u6570\u5305\u88c5\u4e3a\u6570\u7ec4\u3002 \u793a\u4f8b \u4f7f\u7528 String \u8f6c\u6362\uff1a int number = 123; String numberString = Integer.toString(number); char[] numberArray = numberString.toCharArray(); int[] result = new int[numberArray.length]; for (int i = 0; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-65956","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=65956"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65956\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}