ࡱ> 796a bjbjڥڥ .R\R\ x$Nn999CCC9C9CCCKt?*C0 CiCCHC X. 9999> Z: Arrays Arrays are data structures consisting of related data items of the same type using contiguous memory locations. Well be using static arrays (stays the same use once created). Array elements are numbered the same as C++ numbering scheme. (0 ( n-1, where n is the array size.) myarray[0]=7 myarray[1]=198 myarray[2]=-225 myarray[3]=-75 myarray[4]=4 myarray[5]=118 myarray[6]=-36 myarray[7]=94 Every array is Java knows its own length and maintains this information in a variable called length. myarray.length Arrays: Declaring and Allocating Arrays are allocated dynamically with the new operator. int myarray[] = new int[4]; or int myarray[]; myarray = new int [4]; or String palindrome[]= new String[50], reverse[]= new String[50]; or double[] sal1,sal2; //array type and brackets can be used at the //beginning to indicate that all identifiers listed represent arrays. Allocating arrays and initializing its elements: Look p318 InitArray Program Initializer Lists int temp[] = {50,60,70,80,90,100}; array size is determined by the number of elements in the initializer list. new is not required when using initializer lists. Look p320 Use of initializer list final is like const from C++ Examples of Arrays: Summing the Elements of an Array p322 Histograms p323 ***Elements as Counters p325 (RollDie) Student Poll Program p326 Assignment: Frequency of Die Sums Program Simulate the rolling of two dice. Use your roll() method. Sum the rolls (numbers should vary from 2 to 12). Your program should roll the die 36,000 times. Use a single-subscripted array to tally the numbers of times each possible sum appears. Display the complete frequency array in a dialog box or using System.out.print/println() c  ? j n ! ! ɷɫɞscVGh h CJOJQJaJh >*CJOJQJaJh h >*CJOJQJaJh}h}>*CJOJQJaJh}h}CJOJQJaJh}CJOJQJaJh}>*CJOJQJaJhI'CJOJQJaJ" jh!Mh!MCJOJQJaJh!MCJOJQJaJh!M>*CJOJQJaJhq<>*CJOJQJaJh!Mh!M>*CJOJQJaJxy / @ R c r   ? @ x y gdI'gd!M   " # o p ! 1 X gd}`gd}! M W q r s y {o`hhCJ$OJQJaJ$hCJ$OJQJaJ$h}CJ$OJQJaJ$hI9CJ$OJQJaJ$hhCJ$OJQJaJ$hh CJ$OJQJaJ$hh}CJ$OJQJaJ$hh}>*CJ$OJQJaJ$hCJOJQJaJh=-CJOJQJaJhCJOJQJaJh CJOJQJaJX r s t u v w x y gd},1h/ =!"#$% s2 0@P`p2( 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p8XV~ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@ 0@_HmH nH sH tH @`@ NormalCJ_HaJmH sH tH DA D Default Paragraph FontRiR  Table Normal4 l4a (k (No List PK![Content_Types].xmlN0EH-J@%ǎǢ|ș$زULTB l,3;rØJB+$G]7O٭VvnB`2ǃ,!"E3p#9GQd; H xuv 0F[,F᚜K sO'3w #vfSVbsؠyX p5veuw 1z@ l,i!b I jZ2|9L$Z15xl.(zm${d:\@'23œln$^-@^i?D&|#td!6lġB"&63yy@t!HjpU*yeXry3~{s:FXI O5Y[Y!}S˪.7bd|n]671. tn/w/+[t6}PsںsL. J;̊iN $AI)t2 Lmx:(}\-i*xQCJuWl'QyI@ھ m2DBAR4 w¢naQ`ԲɁ W=0#xBdT/.3-F>bYL%׭˓KK 6HhfPQ=h)GBms]_Ԡ'CZѨys v@c])h7Jهic?FS.NP$ e&\Ӏ+I "'%QÕ@c![paAV.9Hd<ӮHVX*%A{Yr Aբ pxSL9":3U5U NC(p%u@;[d`4)]t#9M4W=P5*f̰lk<_X-C wT%Ժ}B% Y,] A̠&oʰŨ; \lc`|,bUvPK! ѐ'theme/theme/_rels/themeManager.xml.relsM 0wooӺ&݈Э5 6?$Q ,.aic21h:qm@RN;d`o7gK(M&$R(.1r'JЊT8V"AȻHu}|$b{P8g/]QAsم(#L[PK-![Content_Types].xmlPK-!֧6 0_rels/.relsPK-!kytheme/theme/themeManager.xmlPK-!R%theme/theme/theme1.xmlPK-! ѐ' theme/theme/_rels/themeManager.xml.relsPK] !   X  8@0(  B S  ?' >*urn:schemas-microsoft-com:office:smarttags PersonName ")18BIT[elt{|OV"*19BJT\emt||#(ps333333333333333333333333 b ?y!qxBbqr   I'=-I9q<!MBS}tVl@@UnknownG.Cx Times New Roman5Symbol3. .Cx ArialCN@Comic Sans MS;WingdingsA$BCambria Math"qh Sg Sg   !243KP ?BS2!xx Arrays cbellaceraBellacera, Carolyn Oh+'0|  8 D P\dltArrays cbellaceraNormalBellacera, Carolyn2Microsoft Office Word@@t@t  ՜.+,0 hp  Mount Sinai School District  Arrays Title  !"#$%'()*+,-/0123458Root Entry F:Data 1TableWordDocument.SummaryInformation(&DocumentSummaryInformation8.CompObjr  F Microsoft Word 97-2003 Document MSWordDocWord.Document.89q