Java Learning (v) Java class inheritance

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.