Java Data Structure----Array Chapter

Source: Internet
Author: User

1. As one of Java's most common data structures, the use of arrays is relatively simple, showing the number of comparisons that are commonly used by arrays in cases where duplicate values are allowed and not allowed

2. After the encapsulated code:

1  PackageCom.cn.higharray;2 /**3 * Further encapsulation of the array, more convenient to call.4  * @authorAdministrator5  *6  */7  Public classHigharray {8 Private Long[] A;9 Private intNelems;Ten  PublicHigharray (intmax) { OneA =New Long[Max]; ANelems = 0; - } -  Public BooleanFindLongkey) { the     intJ; -      for(j = 0;j<nelems;j++) -         if(A[j] = =key) -              Break; +     if(J = =nelems) -         return false; +     Else A         return true; at } -  Public voidInsertLongvalue) { -A[nelems] =value; -nelems++; - } -  Public BooleanDeleteLongvalue) { in     intJ; -      for(j = 0;j < Nelems;j + +) to         if(A[j] = =value) +              Break; -     if(J = =nelems) the         return false; *     Else{ $          for(intK = J;k < Nelems;k + +)Panax NotoginsengA[k] = a[k+1]; -Nelems--; the         return true; +         } A } the  Public voiddisplay () { +      for(intj = 0;j < Nelems;j + +) - System.out.print (A[j]); $System.out.println (""); $ } -}

Java Data Structure----Array Chapter

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.