On the command line, enter: javadoc-d myhelp (file name)-author (parameter name)-version (parameter name) Arraytool.java (class name)
1 /**2 This is a tool class that can operate on an array, which provides functions such as getting the most value, sorting, and so on. 3 @authorZhang San4 @versionV1.15 6 */7 8 Public classArraytool9 {Ten /** One Null parameter constructor. A */ - PrivateArraytool () {} - the /** - gets the maximum value in a shaped array. - @paramarr receives an array of type int. - @returnreturns the maximum value in the array. + */ - Public Static intGetmax (int[] arr) + { A intMax = 0; at for(intX=1; x<arr.length; X + +) - { - if(arr[x]>Arr[max]) -Max =x; - } - returnArr[max]; in } - to /** + gets the minimum value in a shaped array. - @paramarr receives an array of type int. the @returnreturns a minimum value in the array. * */ $ Public Static intGetmin (int[] arr)Panax Notoginseng { - intMin = 0; the for(intX=1; x<arr.length; X + +) + { A if(arr[x]<Arr[min]) theMin =x; + } - returnArr[min]; $ } $ /** - Select Sort int array. - @paramarr receives an array of type int. the */ - Public Static voidSelectsort (int[] arr)Wuyi { the for(intx=0; X<arr.length-1; X + + ) - { Wu for(inty=x+1; y<arr.length; y++) - { About if(arr[x]>Arr[y]) $ { - swap (arr,x,y); - } - } A } + } the /** - bubble sort int array. $ @paramarr receives an array of type int. the */ the Public Static voidBubblesort (int[] arr) the { the for(intx=0; X<arr.length-1; X + + ) - { in for(inty=0; y<arr.length-x-1; y++) the { the if(arr[y]>arr[y+1]) About { theSwap (arr,y,y+1); the } the } + } - } the /**Bayi the permutation of the positions of the elements in the array. the @paramarr receives an array of type int. the @parama position to displace - @paramb The position to displace - */ the Private Static voidSwapint[] arr,intAintb) the { the inttemp =Arr[a]; theArr[a] =Arr[b]; -ARR[B] =temp; the } the /** the used to print the elements in an array. The print form is: [Elemet1, Element2, ...]94 */ the Public Static voidPrintArray (int[] arr) the { theSystem.out.print ("[");98 for(intx=0; x<arr.length; X + +) About { - if(x!=arr.length-1)101System.out.print (arr[x]+ ",");102 Else103System.out.println (arr[x]+ "]");104 } the }106}
Java Learning Help Document authoring