{"id":36544,"date":"2024-11-26T14:24:28","date_gmt":"2024-11-26T06:24:28","guid":{"rendered":"https:\/\/fwq.ai\/blog\/36544\/"},"modified":"2024-11-26T14:24:28","modified_gmt":"2024-11-26T06:24:28","slug":"java%e4%b8%ad%e6%9c%89%e5%93%aa%e4%ba%9b%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/36544\/","title":{"rendered":"java\u4e2d\u6709\u54ea\u4e9b\u6570\u7ec4"},"content":{"rendered":"<blockquote><p>\n  java \u4e2d\u7684\u6570\u7ec4\u7c7b\u578b\u5305\u62ec\uff1a\u57fa\u672c\u7c7b\u578b\u6570\u7ec4\uff08\u5982 int[] \u548c char[]\uff09\u5bf9\u8c61\u6570\u7ec4\uff08\u5982 string[] \u548c employee[]\uff09\u591a\u7ef4\u6570\u7ec4\uff08\u5982 int[][] \u548c string[][]\uff09\u6570\u7ec4\u53ef\u4ee5\u901a\u8fc7\u4e0b\u6807 [] \u8fd0\u7b97\u7b26\u8bbf\u95ee\u5143\u7d20\uff0c\u5e76\u4f7f\u7528 .length \u5c5e\u6027\u83b7\u53d6\u5176\u957f\u5ea6\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/12\/2024111209550117942.jpg\" class=\"aligncenter\" title=\"java\u4e2d\u6709\u54ea\u4e9b\u6570\u7ec4\u63d2\u56fe\" alt=\"java\u4e2d\u6709\u54ea\u4e9b\u6570\u7ec4\u63d2\u56fe\" \/><\/p>\n<p><strong>Java \u4e2d\u7684\u6570\u7ec4<\/strong><\/p>\n<p><strong>1. \u57fa\u672c\u7c7b\u578b\u6570\u7ec4<\/strong><\/p>\n<ul>\n<li> <strong>int[]<\/strong>\uff1a\u5b58\u50a8\u6574\u578b\u503c<\/li>\n<li> <strong>long[]<\/strong>\uff1a\u5b58\u50a8\u957f\u6574\u578b\u503c<\/li>\n<li> <strong>short[]<\/strong>\uff1a\u5b58\u50a8\u77ed\u6574\u578b\u503c<\/li>\n<li> <strong>byte[]<\/strong>\uff1a\u5b58\u50a8\u5b57\u8282\u503c<\/li>\n<li> <strong>float[]<\/strong>\uff1a\u5b58\u50a8\u6d6e\u70b9\u503c<\/li>\n<li> <strong>double[]<\/strong>\uff1a\u5b58\u50a8\u53cc\u7cbe\u5ea6\u6d6e\u70b9\u503c<\/li>\n<li> <strong>char[]<\/strong>\uff1a\u5b58\u50a8\u5b57\u7b26\u503c<\/li>\n<li> <strong>boolean[]<\/strong>\uff1a\u5b58\u50a8\u5e03\u5c14\u503c<\/li>\n<\/ul>\n<p><strong>2. \u5bf9\u8c61\u6570\u7ec4<\/strong><\/p>\n<ul>\n<li> <strong>String[]<\/strong>\uff1a\u5b58\u50a8\u5b57\u7b26\u4e32<\/li>\n<li> <strong>Integer[]<\/strong>\uff1a\u5b58\u50a8 Integer \u5bf9\u8c61<\/li>\n<li> <strong>Double[]<\/strong>\uff1a\u5b58\u50a8 Double \u5bf9\u8c61<\/li>\n<li> <strong>Employee[]<\/strong>\uff1a\u5b58\u50a8 Employee \u5bf9\u8c61\uff08\u81ea\u5b9a\u7fa9\u985e\u5225\uff09<\/li>\n<\/ul>\n<p><strong>3. \u591a\u7ef4\u6570\u7ec4<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li> <strong>int[][]<\/strong>\uff1a\u5b58\u50a8\u6574\u578b\u503c\u7684\u4e8c\u7ef4\u6570\u7ec4<\/li>\n<li> <strong>String[][]<\/strong>\uff1a\u5b58\u50a8\u5b57\u7b26\u4e32\u7684\u4e8c\u7ef4\u6570\u7ec4<\/li>\n<\/ul>\n<p><strong>4. \u6570\u7ec4\u7684\u58f0\u660e<\/strong><\/p>\n<pre>int[] numbers;\nString[] names;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u6570\u7ec4\u7684\u521d\u59cb\u5316<\/strong><\/p>\n<pre>int[] numbers = {1, 2, 3, 4, 5};\nString[] names = {\"John\", \"Mary\", \"Bob\"};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>6. \u6570\u7ec4\u7684\u8bbf\u95ee<\/strong><\/p>\n<p>\u4f7f\u7528\u4e0b\u6807 [] \u8fd0\u7b97\u7b26\u8bbf\u95ee\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\uff1a<\/p>\n<pre>int firstNumber = numbers[0];\nString thirdName = names[2];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>7. \u6570\u7ec4\u7684\u957f\u5ea6<\/strong><\/p>\n<p>\u4f7f\u7528 .length \u5c5e\u6027\u83b7\u53d6\u6570\u7ec4\u7684\u957f\u5ea6\uff1a<\/p>\n<pre>int arrayLength = numbers.length;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fjava\u4e2d\u6709\u54ea\u4e9b\u6570\u7ec4\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>java \u4e2d\u7684\u6570\u7ec4\u7c7b\u578b\u5305\u62ec\uff1a\u57fa\u672c\u7c7b\u578b\u6570\u7ec4\uff08\u5982 int[] \u548c char[]\uff09\u5bf9\u8c61\u6570\u7ec4\uff08\u5982 string[] \u548c employee[]\uff09\u591a\u7ef4\u6570\u7ec4\uff08\u5982 int[][] \u548c string[][]\uff09\u6570\u7ec4\u53ef\u4ee5\u901a\u8fc7\u4e0b\u6807 [] \u8fd0\u7b97\u7b26\u8bbf\u95ee\u5143\u7d20\uff0c\u5e76\u4f7f\u7528 .length \u5c5e\u6027\u83b7\u53d6\u5176\u957f\u5ea6\u3002 Java \u4e2d\u7684\u6570\u7ec4 1. \u57fa\u672c\u7c7b\u578b\u6570\u7ec4 int[]\uff1a\u5b58\u50a8\u6574\u578b\u503c long[]\uff1a\u5b58\u50a8\u957f\u6574\u578b\u503c short[]\uff1a\u5b58\u50a8\u77ed\u6574\u578b\u503c byte[]\uff1a\u5b58\u50a8\u5b57\u8282\u503c float[]\uff1a\u5b58\u50a8\u6d6e\u70b9\u503c double[]\uff1a\u5b58\u50a8\u53cc\u7cbe\u5ea6\u6d6e\u70b9\u503c char[]\uff1a\u5b58\u50a8\u5b57\u7b26\u503c boolean[]\uff1a\u5b58\u50a8\u5e03\u5c14\u503c 2. \u5bf9\u8c61\u6570\u7ec4 String[]\uff1a\u5b58\u50a8\u5b57\u7b26\u4e32 Integer[]\uff1a\u5b58\u50a8 Integer \u5bf9\u8c61 Double[]\uff1a\u5b58\u50a8 Double \u5bf9\u8c61 Employee[]\uff1a\u5b58\u50a8 Employee \u5bf9\u8c61\uff08\u81ea\u5b9a\u7fa9\u985e\u5225\uff09 3. \u591a\u7ef4\u6570\u7ec4 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b int[][]\uff1a\u5b58\u50a8\u6574\u578b\u503c\u7684\u4e8c\u7ef4\u6570\u7ec4 String[][]\uff1a\u5b58\u50a8\u5b57\u7b26\u4e32\u7684\u4e8c\u7ef4\u6570\u7ec4 4. \u6570\u7ec4\u7684\u58f0\u660e int[] numbers; String[] names; \u767b\u5f55\u540e\u590d\u5236 5. \u6570\u7ec4\u7684\u521d\u59cb\u5316 int[] numbers [&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-36544","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/36544","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=36544"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/36544\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=36544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=36544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=36544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}