JavaJavapenggang@mail.hust.edu.cn3.4—————,,—JavanewJava.length1——typearrayName[]type[]arrayName(type)JavaarrayName[]intarrayName[]int[]arrayName1——JavanewJavatypevar_name[]=newtype[size];type[]var_name=newtype[size];int[]a=newint[5];int[]aa=newint[5];Java“”DatedateArray[]Date[]dateArray;DateCC++Java[]1——int[]intArray={1,2,3,4};//4//intnewtypearrayName[]=newtype[arraySize];type[]arrayName=newtype[arraySize];typearrayName[]=newtype[arraySize];nullNullPointExceptionnewarrayName[0]=newtype(paramList);//()…arrayName[arraySize-1]=newtype(paramList);1——StringstringArrar[];//StringstringArray=newString[3];//stringArray3//nullstringArray[0]=newString(“how”);stringArray[1]=newString(“are”);stringArray[2]=newString(“you”);1——newarrayName[index]indexarrayName[2],arrayName[i],arrayName[arrayName.length-1]011——CC++JavalengthintArray.lengthintArrayArrayIndexOutOfBoundsExceptionJavaSwapInt.java,P1633.9,P159Javajava.util.RandomintlongfloatdoubleGoussianjava.lang.MathRandom()doubleRandom(1)publicRandom()//Javaseed(2)publicRandom(longseed)//(1)publicsynonronizedvoidsetSeed(longseed)//seed(2)publicintnextInt()//(3)publiclongnextLong()//long(4)publicfloatnextFloat()//Float(5)publicdoublenextDouble()//Double(6)publicsynchronizeddoublenextGoussian()//doubleGoussian——WrapperclassJava8JavaWrapperclasswrapper:,,Java8java.langNumberbooleanBooleanintIntegerbyteBytelongLongcharCharacterfloatFloatshortShortdoubleDoubleIntegerIntegerpublicstaticfinalMIN_VALUE=0x80000000;publicstaticfinalMAX_VALUE=0x7fffffff;IntegerpublicInteger(intvalue){...}publicInteger(Strings){...}intprimitiveInt=64;IntegerwrappedInt=newInteger(primitiveInt);Stringstr=64;IntegerwrappedInt=newInteger(str);intinttoString()3publicStringtoString(){...}publicstaticStringtoString(inti){...}publicstaticStringtoString(inti,intradix){...}IntegerIntergerintIntegerintIntegerintIntegera=newInteger(64);Stringstr1=a.toString();//Integer—”40”intb=64;Stringstr2=Integer.toString(b,16);//int—”40”intpublicstaticintparseInt(Strings){...}publicstaticintparseInt(Strings,intradix){...}inta=Integer.parseInt(486,10);NumberFormatExceptioninta=Integer.parseInt(99,8);//NumberFormatExceptionIntegerIntegerpublicstaticIntegervalueOf(Strings){...}publicstaticIntegervalueOf(Strings,intradix){...}Integerint“newInteger(Integer.parseInt(s,radix))”parseInt()intnewIntegerintIntegerIntegerintintValue()publicintintValue(){...}Integerx=newInteger(686);inta=x.intValue();//686a(7)IntegerintpublicbytebyteValue(){...}publicshortshortValue(){...}publiclonglongValue(){...}publicfloatfloatValue(){...}publicdoubledoubleValue(){...}Object1——typearrayName[][]intintArray[][]type[][]arrayName;new—Java——inta[][]=newint[3][4];inta[][]=newint[3][];a[0]=newint[4];a[1]=newint[4];a[2]=newint[4];a[3][4]1——intintArray[][]={{1,2},{2,3},{3,4}};1——1.typearrayName[][]=newtype[arraylength1][arraylength2]inta[][]=newint[2][3]2.Strings[][]=newString[2][];s[0]=newString[2];s[1]=newString[3];s[0][0]=newString(“Good”);s[0][1]=newString(“Luck”);s[1][0]=newString(“to”);s[1][1]=newString(“you”);s[1][1]=newString(“!”);1——1——java.util.ArraysJavajava.utilArraysjava.utilVectorVectorintbinarySearch(typea[],typekey)aakeya“-(-1)”booleanequals(typea[],typea2[])nullvoidfill(typea[],typeval)voidfill(typea[],intfromIndx,inttoIndex,typeval)a[fromIndx]a[toIndex]fromIndx==toIndex1——java.util.Arrays1——java.util.Arraysvoidsort(typea[])voidsort(typea[],intfromIndx,inttoIndex)a[fromIndx]a[toIndex]fromIndx==toIndexQuickSortn*log(n)JDK1——java.lang.Systemvoidarraycopy(Objectsrc,intsrc_position,Objectdst,intdst_position,intlength)JDKJava2JavaJava