{"id":317,"date":"2023-09-16T10:32:10","date_gmt":"2023-09-16T02:32:10","guid":{"rendered":""},"modified":"2023-09-18T11:49:45","modified_gmt":"2023-09-18T03:49:45","slug":"java%e6%95%b0%e7%bb%84%e5%88%9d%e5%a7%8b%e5%8c%96%e8%b5%8b%e5%80%bc_%e6%95%b0%e7%bb%84%e5%88%9d%e5%a7%8b%e5%8c%96%e4%b8%8e%e8%b5%8b%e5%80%bc","status":"publish","type":"post","link":"https:\/\/mushiming.com\/317.html","title":{"rendered":"java\u6570\u7ec4\u521d\u59cb\u5316\u8d4b\u503c_\u6570\u7ec4\u521d\u59cb\u5316\u4e0e\u8d4b\u503c"},"content":{"rendered":"
\u6570\u7ec4\u521d\u59cb\u5316\u4e0e\u8d4b\u503c<\/p>\n
2009-09-17<\/p>\n
\u5982\u679c\u6709\u51e0\u4e2aobject\uff0c\u4ed6\u4eec\u7684\u7c7b\u578b\u662f\u76f8\u540c\u7684\u3002\u521b\u5efa\u5b83\u4eec\u7684\u65f6\u5019\uff0c\u5b83\u4eec\u53ef\u80fd\u5728\u5806\u91cc\u7684\u5404\u4e2a\u6563\u843d\u4f4d\u7f6e\u4ea7\u751f\uff0c\u8fd9\u6837\u7684\u8bdd\uff0c\u5b58\u53d6\u6548\u7387\u5c31\u4f1a\u4e0d\u9ad8\u3002\u65e2\u7136\u5b83\u4eec\u7684\u7c7b\u578b\u662f\u76f8\u540c\u7684\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u7528\u8fde\u7eed\u7684\u5806\u7a7a\u95f4\u6765\u5b58\u653e\u5b83\u4eec\uff0c\u5e76\u4e14\u7528\u540c\u4e00\u4e2a\u6807\u8bc6\u7b26\u5c01\u88c5\u3002\u5bf9\uff0c\u8fd9\u4e2a\u5c31\u662f\u6570\u7ec4\u7684\u6765\u7531\u4e86\u3002\u7531\u4e8e\u8fd9\u4e9b\u5bf9\u8c61\u4f7f\u7528\u540c\u4e00\u4e2a\u6807\u8bc6\u7b26\uff0c\u6240\u4ee5\u8981\u64cd\u7eb5\u6570\u7ec4\u5185\u7684\u5bf9\u8c61\uff0c\u9700\u8981\u4f7f\u7528\u65b9\u62ec\u53f7\u4e0b\u6807\u64cd\u4f5c\u7b26[]\u3002<\/p>\n
\u521b\u5efa\u5e76\u521d\u59cb\u5316\u4e00\u4e2a\u6570\u7ec4\u5e76\u8d4b\u503c<\/p>\n
public class ArrayIni {
\n <\/p>\n
public static void main(String[] args){
\n <\/p>\n
int[] energy = {10, 30, 60, 100, 150};<\/p>\n
int[] powerMood;<\/p>\n
powerMood = energy;<\/p>\n
for (int i = 0; i < powerMood.length; i++)<\/p>\n
powerMood[i] = powerMood[i] * 2;<\/p>\n
for (int i = 0; i < energy.length; i++){
\n <\/p>\n
System.out.println(\"\u5404\u5f62\u6001\u7206\u88c2\u6a21\u5f0f\u80fd\u91cf\u503c\u4e3a\" + energy[i] );<\/p>\n
}<\/p>\n
}<\/p>\n
}<\/p>\n
\u5982\u7a0b\u5e8f\u6240\u793a\uff0c\u5728\u5806\u91cc\u521b\u5efa5\u4e2aint\u5bf9\u8c61\uff0c\u7136\u540e\u7528energy\u6765\u6807\u8bc6\u8fd9\u4e00\u5757\u8fde\u7eed\u7684\u5806\u7a7a\u95f4\u3002\u8fd95\u4e2a\u5bf9\u8c61\u5206\u522b\u8868\u793a\uff0c\u5e7c\u5e74\u671f\u3001\u6210\u957f\u671f\u3001\u6210\u719f\u671f\u3001\u5b8c\u5168\u4f53\u3001\u7a76\u6781\u4f53\u7684\u80fd\u91cf\u503c\u3002<\/p>\n
\u7136\u540e\u6211\u4eec\u53c8\u5b9a\u4e49\u4e00\u4e2a\u6807\u5fd7\u7b26\uff0c\u4e5f\u53ef\u4ee5\u7406\u89e3\u4e3a\u5f15\u7528\uff0c powerMood = energy \u7684\u610f\u601d\u662f\u8bf4\uff0c\u5c06powerMood\u4e5f\u6307\u5411\u90a3\u4e00\u5757\u8fde\u7eed\u7684\u5806\u7a7a\u95f4\u3002<\/p>\n
\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528\u5faa\u73af\uff0c\u64cd\u7eb5powerMood\u6307\u5411\u7684\u5bf9\u8c61\uff0c\u4f7f\u5b83\u4eec\u7684\u503c\u6269\u5927\u4e24\u500d\u3002\u7136\u540e\u6211\u4eec\u770b\u4e00\u4e0b\uff0cenergy\u6307\u5411\u7684\u5806\u91cc\u7684\u5bf9\u8c61\u53d1\u751f\u4ec0\u4e48\u53d8\u5316\u3002<\/p>\n
\u7a0b\u5e8f\u8f93\u51fa\u4e3a\uff1a<\/p>\n
\u5404\u5f62\u6001\u7206\u88c2\u6a21\u5f0f\u80fd\u91cf\u503c\u4e3a20<\/p>\n
\u5404\u5f62\u6001\u7206\u88c2\u6a21\u5f0f\u80fd\u91cf\u503c\u4e3a60<\/p>\n
\u5404\u5f62\u6001\u7206\u88c2\u6a21\u5f0f\u80fd\u91cf\u503c\u4e3a120<\/p>\n
\u5404\u5f62\u6001\u7206\u88c2\u6a21\u5f0f\u80fd\u91cf\u503c\u4e3a200<\/p>\n
\u5404\u5f62\u6001\u7206\u88c2\u6a21\u5f0f\u80fd\u91cf\u503c\u4e3a300<\/p>\n
\u5f88\u660e\u663e\uff0c\u6211\u4eec\u53ea\u662f\u4fee\u6539\u4e86powerMood\u5f15\u7528\uff0c\u4f46\u662fenergy\u5f15\u7528\u4e5f\u53d1\u751f\u4e86\u53d8\u5316\u3002<\/p>\n
\u6570\u7ec4\u7684\u5143\u7d20<\/p>\n
\u6570\u7ec4\u7684\u5143\u7d20\u53ef\u4ee5\u662f\u5bf9\u8c61\uff0c\u4e5f\u53ef\u4ee5\u662f\u57fa\u672c\u6570\u636e\u7c7b\u578b\u3002<\/p>\n
\u6570\u7ec4\u6709\u4e00\u4e2a\u56fa\u6709\u6210\u5458length\uff0c\u901a\u8fc7\u5b83\u53ef\u4ee5\u77e5\u9053\u6570\u7ec4\u5185\u6709\u591a\u5c11\u4e2a\u5bf9\u8c61\u3002Java\u6570\u7ec4\u662f\u4ece\u7b2c0\u4e2a\u5143\u7d20\u5f00\u59cb\uff0c\u6240\u4ee5\u80fd\u4f7f\u7528\u7684\u6700\u5927\u6570\u7ec4\u4e0b\u6807\u4e3alength - 1\u3002\u4e00\u65e6\u8bbf\u95ee\u4e0b\u6807\u8fc7\u754c\uff0c\u5c31\u4f1a\u51fa\u73b0\u5f02\u5e38\uff0c\u5c31\u662f\u8fd0\u884c\u65f6\u9519\u8bef\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"java\u6570\u7ec4\u521d\u59cb\u5316\u8d4b\u503c_\u6570\u7ec4\u521d\u59cb\u5316\u4e0e\u8d4b\u503c\u6570\u7ec4\u521d\u59cb\u5316\u4e0e\u8d4b\u503c2009-09-17\u5982\u679c\u6709\u51e0\u4e2aobject\uff0c\u4ed6\u4eec\u7684\u7c7b\u578b\u662f\u76f8\u540c\u7684\u3002\u521b\u5efa\u5b83\u4eec\u7684\u65f6\u5019\uff0c\u5b83...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/317"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=317"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/317\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}