"Data Structure" array operation (Higharrayapp.java)

Source: Internet
Author: User

1 //Java data Structures and algorithms second Edition Marquez2 //operation of the array3 4  PackageFirst ;5 6 classHigharray {7     Private Long[] A;8     Private intNelems;9     Ten      PublicHigharray (intmax) { OneA =New Long[Max]; ANelems = 0; -     } -      the      Public voidInsertLongvalue) { -A[nelems] =value; -nelems++; -     } +      -      Public voiddisplay () { +          for(intj = 0; J < Nelems; J + +) { ASystem.out.print (A[j] + ""); at         } -System.out.println (""); -     } -      -      Public BooleanFindLongSearchkey) { -         intJ; in          for(j = 0; J < Nelems; J + +)  -             if(A[j] = = Searchkey) Break; to                  +         if(J = =nelems) -             return false; the         Else *             return true; $     }Panax Notoginseng      -      Public BooleanDeleteLongvalue) { the         intJ; +          for(j = 0; J < Nelems; J + +) A             if(A[j] = = value) Break; the          +         if(J = =nelems) -             return false; $         Else { $              for(intK = J; K < Nelems; k++) -A[k] = a[k + 1]; -nelems--; the             return true; -         }Wuyi     } the}//end of class Higharray -  Wu  -  Public classHigharrayapp { About      Public Static voidMain (string[] args) { $         intmaxSize = 100; -Higharray arr =NewHigharray (maxSize); -          -Arr.insert (77); AArr.insert (99); +Arr.insert (44); theArr.insert (55); -Arr.insert (22); $Arr.insert (88); theArr.insert (11); theArr.insert (00); theArr.insert (66); theArr.insert (33); - Arr.display (); in          the         intSearchkey = 35; the         if(Arr.find (searchkey)) AboutSystem.out.println ("Found" +searchkey); the         Else theSystem.out.println ("Can ' t Find" +searchkey); the          +Arr.delete (00); -Arr.delete (55); theArr.delete (99);Bayi          the         if(Arr.delete (23429) = =false) theSystem.out.println ("Can ' t delete" + 23429); -          - Arr.display (); the     } the}//end of class Higharrayapp the  the  - 
Operation Result:
2342977 44 22 88 11 66 33, 0/  t Find 35can ' t  

"Data Structure" array operation (Higharrayapp.java)

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.