1. Making a document for a tool class
javadoc-d Directory-author-version Arraytool.java
Instance:
classarraydemo{ Public Static voidMain (string[] args) {int[] arr = {23,34,54,65,57,7}; //iterating through an arrayArraytool.printarray (arr); //gets the maximum value in the array intMax =Arraytool.getmax (arr); System.out.println ("The maximum value in the array is" +max); //gets the index of the element in the array intindex = Arraytool.getindex (arr,57); System.out.println ("57 index position in the array is" +index); }}
Document type of the Build tool class
javac-d doc-author-version Arraytool.java
/*** Array Manipulation tool class *@authorGreymouster *@versionv1.0*/ Public classarraytool{/*** Private construction methods prohibit external instantiation of objects*/ PrivateArraytool () {}/*** Traversal Array method after traversal for [element 1, Element 2, Element 3,....] *@paramarr to traverse the array*/ Public Static voidPrintArray (int[] arr) {System.out.print ("["); for(intx=0;x<arr.length;x++){ if(x = = Arr.length-1) {System.out.println (arr[x]+"]"); }Else{System.out.print (arr[x]+","); } } } /*** method to get the maximum value in the array *@paramArr Array *@returnreturns the maximum value in an array*/ Public Static intGetmax (int[] arr) { //the element that joins the array is the maximum value intmax = Arr[0]; for(intx=1;x<arr.length;x++){ if(max<Arr[x]) {Max=Arr[x]; } } returnMax; } /*** Get the index of the values in the array *@paramthe values in the ARR array value array *@returnIndex returns the indexed value in the array if there is no return-1. */ Public Static intGetIndex (int[] arr,intvalue) { intindex =-1; for(intx=0;x<arr.length;x++){ if(Arr[x] = =value) {Index=x; } } returnindex; }}
Java Learning (v) Java class inheritance