My add and remove program

I am asked to create an add method with the following rules:
When adding new elements, check to ensure there is room in the array data. If there is no unused array index, grow the array by delta elements. When removing existing elements, shrink the array by delta elements whenever there is room to add more than delta elements. In other words, leave no more than delta empty array locations at any time. The array must have from 0 through delta empty indexes at all times. The following assertions must pass.
This add method must work for any data type. And so far the method that I have create is:
public boolean add(E element) {
    boolean result = false;
    Object[] temp = new Object[data.length+delta];
        if (data.length == n){
            for (int i = 0; i<data.length; i++){
                temp[i] = data;
data = temp;
for (int i=0; i<data.length; i++){
if (data[i].equals(element))
result = false;
else{
n++;
data[n-1] = element;
result = true;
return result;
The problem with this code is that when I try to add an interger it always gives me a null point exception because all the value in the array are set as null the very first time, how do I get this method to work the way it's suppose to be??

okay guys, so here's now for my remove method:
public boolean remove(E element) {
          boolean result = true;
          int position = 0;
          int count = 0;
          for (int i = 0; i <= n; i++) {
               if (element.equals(data)) {
                    result = true;
                    position = i;
          if (result == true) {
               for (int j = position; j < n - 1; j++) {
                    data[position] = data[position + 1];
               data[n - 1] = null;
               n--;
          for (int k = 0; k< data.length; k++) {
               if (data[k] == null)
                    count++;
          if (count>=delta){
               Object[] temp = new Object[data.length - (count-delta)];
               for (int m = 0; m<temp.length; m++)
                    temp[m] = data[m];
               data = temp;     
          return result;
This method wont work according to the rules:
When removing existing elements, shrink the array by delta elements whenever there is room to add more than delta elements. In other words, leave no more than delta empty array locations at any time. The array must have from 0 through delta empty indexes at all times. The following assertions must pass.
why is that?? can someone help me?
My teacher has provided me with this test method:
@Test
     public void testGrowAndShrink() {
       Set<Integer> ints = new ArraySet<Integer>(5, 10);
       for (int i = 1; i <= 20; i++)
         ints.add(i);
       assertEquals(20, ints.size());
       // Array has now grown twice by 10 elements (capacity went from 5 to 25)
       assertEquals(25, ints.capacity());
       for (int i = 1; i <= 4; i++)
         ints.remove(i);
       assertEquals(16, ints.size());
       assertEquals(25, ints.capacity());
       ints.remove(5);
       // Array shrunk by 10 elements
       assertEquals(15, ints.size());
       assertEquals(15, ints.capacity());
     } and it didn't pass the assertEquals(15, ints.capacity());
why???
Message was edited by:
aditya15417
Message was edited by:
aditya15417

Similar Messages

  • Cannot uninstall I tunes. In control panel add and remove programs it will not give me the option to remove any of the I tunes. In program files it tells me access denied to remove any of the related items. I have tried using the removal methods from i tu

    My i tunes will not work at all. I have tried all the steps given to remove my I tunes player but in my control panel, add and remove programs it does not give me an option to remove any of the apple/ I tunes. I tried to go to program files and remove all the files but access is denied. This all started about 1 1/2 years ago and with every i tunes update i got more and more errors or problems until it stopped working. At one time i could remove and reinstall i tunes to try to fix it but now i cannot do anything. I believe one of the last  was i could not open i tune because it was being used or was on another network, not 100% sure its been so long and frustrating I quit trying 6 months ago. Hopefully someones got some help !!!
    Thanks I appreciate your time; Philip

    See Troubleshooting issues with iTunes for Windows updates.
    tt2

  • How do I remove Bing from my toolbar at the top of the page. I have already tried both of the suggestions given in the help section; I could not find Bing in my control panel "add and remove programs," and there was one other suggestion which I also tried

    ''locking due the age of this thread - asked and answered''
    I have tried all of the suggestions given by FF in order to remove Bing from my computer but nothing seems to work. I would appreciate some advise. For instance when I go to add and remove programs I can't even find Bing listed. Looking forward to your suggestions. Thanks.
    == This happened ==
    Every time Firefox opened
    == I first installed Firefox

    Right click "Tools". Uncheck "Search Toolbars".

  • How to remove Java Applications from "Add and Remove Programs" list?

    I have deployed my Java applications (both JWS and Applet) via JNLP with allow-offline option enabled and without installer-desc option specified.
    My questions are:
    1. An entry is added to the Add and Remove Programs list after launching the application via JNLP. Is it due to the specification of JNLP or JWS? Is there anyway to prevent this behavior?
    2. I removed my application by clearing the cache via Java Control Panel but the entry for the application is still listed in Add and Remove Programs. How can I remove the entry in the Add and Remove Programs?
    I have tried following methods but neither works:
    1.Go to Add and Remove Programs, and click [remove] button to the right of my application.
    *Warning message like 'Application cannot be uninstalled completely' is thrown.
    2.Follow instructions listed @ [Microsoft Online Support site|http://support.microsoft.com/kb/314481/en-us] to remove my application manually via Windows registry.
    *Couldn't find appropriate registry entry to delete.
    Thanks in advance!

    Hi, guys!
    This issue has been officially approved as a new bug (Bug Id: 6946221) for the JDK 1.6_20(might include any release below) release.
    It will take a couple of days for it to be shown up in the external Bug database. However, once it becomes available for viewing on external Bug database.I would like to encourage your valuable participation to vote on this bug to get it fixed ASAP by the SUN developer teams.
    Java Bug Database @
    [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6946221|http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6946221]
    Voting for the bug @
    [http://bugs.sun.com/bugdatabase/addVote.do?bug_id=6946221|http://bugs.sun.com/bugdatabase/addVote.do?bug_id=6946221]
    Thank you for your cooperation!
    Edited by: Jay-K on Apr 23, 2010 12:14 AM

  • APSB11-05 Does not update the version of ActiveX flash plugin in Add and Remove Programs

    After installing the latest update for flash player and ActiveX flash plugin the version of adobe flash plugin remains with the old version, when it actually updated the plugin. The only way to get it to update is by removing previous version and do a clean install. This can certainly affect our software inventories.
    Is anybody else experiencing this?
    Thank you in advance

    Hi, It has always been recommended to Uninstall any current version of Flash Player prior to Installing the update.
    Flash Player doesn't "add" to what is already there, it's a complete new version.
    I'm not clear on your setup or software inventories. Perhaps some more information would help.
    Thanks,
    eidnolb

  • Add and remove Java

    Hello there..
    i am in msn communities where you can have someone look over your hijack..this and that..
    anyways..i had Judy hijack for me..and she said to uninstall Java..
    well when i went to add and remove programs..there is no remove button..
    She thought i should ask you experts over here what to do..
    Thank you so much..
    Hugs,
    Bren

    i am in msn communities where you can have someone
    look over your hijack..this and that..
    anyways..i had Judy hijack for me..Rephrasing: you want to say that your MSN was hijacked?
    and she said to uninstall Java..Nonsense.
    Anyway if you have problems with Java installed on your machine I suggest you to download and install the latest JRE from Sun:
    http://www.java.com/en/download/manual.jsp

  • How do I uninstall CS2 on a PC when it does not appear in control panel add or remove programs, the hard drive was replaced and the program corrupted.

    how do I uninstall CS2 on a PC when it does not appear in control panel add or remove programs, the hard drive was replaced and the program corrupted.

    reinstall over your current installation and then uninstall, Error: Activation Server Unavailable | CS2, Acrobat 7, Audition 3
    or uninstall manually, Manually remove Adobe Creative Suite 2.x | Windows

  • Why adobe reader x 10.1.3 appears in Add or Remove programs as 116 mb. and in other boxes appears as

    adobe reader x 10.1.3 appears in one box as 116 mb. and in the other 3 as 173 mb in Add or Remove Programs.

    I mean servers, i have this 4 servers and there is installed adobe reader x 10.1.3 in those 4 servers, why appear diferent sizes in the ¨Add or Remove Programs app¨? it´s very different 116mb to 173 mb., i found that because i was searching why in this server with the 116 mb. i can´t enter protected mode, in the other 3 servers (173mb.) i have the adobe reader in protected mode, the 4 servers are mirrors, they have the same software running (with the exception of the adobe reader size).

  • My sister installed page rage on my laptop, tried rmeoving it frodm add and delete programs and it is not there, tried looking for extensions and its not there, but the page rage web search is ther and i cant remove it. need help asap

    find it under add on and extensions, it doesnt appear on add or remove programs. need help asap

    Hi there -
    Thank you for your feedback. If you wish to uninstall our app, you can do so via our official uninstall page: http://www.pagerage.com/uninstall-pagerage.aspx
    If you still need assistance, please feel free to reach out to us by email: [email protected], thanks!

  • Report ID94 specific software registered with Add or Remove Programs = requested software not listed

    Hi All,
    Our company uses SCCM 2007 and we don't really have an SCCM officer here. I kind of try to get things done by googling a lot but for this i can't find a a solution so i open a thread.
    I'm a newbie to SCCM 2007 so I don't know if i'm about to ask a dumb question but here I go.
    I'm trying to pull out a report for the count of computers that run a desktop version of our Ticketing Tool.
    I found the perfect standard report for this in SCCM 2007 which is: Count of instances of specific software registered with Add or Remove Programs.
    in there i have to set two values: 1) the software that i'm willing to count, 2) the collection in which to search.
    for value number 2 I have no problems.
    my problem is in value number 1. When I click the value button to list all known software, he lists all software in a alphabetic way. problem is that it stops at letter "I"... the software i'm looking for starts with an O so it's not listed.
    also if I type the software and then click Values... it replies that it couldn't find the software.
    am I doing something wrong?

    it sound like you are using the filter option with in the old and "crappy" ASP reports. first you should stop using then and only  use the SSRS reports. secondly the filter option will only show the first 1000 rows, there is a reg key to
    allow it to show more.
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

  • Uninstall firefox after trying add and remove akso Mozilla,s instructions

    I am using Mozilla Firefox version !8.0(x86 en gb on windows Xp) I wish to un-install Mozilla Firefox. I tried the usual "Add and Remove" from Control Panel, this did not work which in its self is odd. I then tried the Mozilla site and followed those instructions which failed also.It makes me feel uncomfortable that removing a program is made so difficult
    Please advise
    Mike R

    Seeing a couple of errors in the system log is not that unusual, but the number you are seeing is indicating a real problem.
    Did you double-click any of the errors in System Events? It would open a pop-up and give more detailed information on the error and usually has a link to the Microsoft help website concerning that specific error. It is likely the "msi" error is significant, as that is a Microsoft installer file (often used for uninstall also). It seems that either Control Panel is messing up or the msi process is crashing for some reason. The information in that error may contain the answer. If there are error numbers, you could do a search for that error number.
    When you say you "re-formatted" your computer, what exactly do you mean? Did you re-install Windows?
    SparkTrust PC Cleaner could possibly be the culprit. Security software, by design, watches for processes that try to make changes to your computer. Along with cleaning, it also claims to "optimize" the registry, which can lead to big trouble if a critical key is removed by accident. I use Registry Mechanic, but with any cleaner, I never allow it to make changes until I have a chance to examine each proposed change. The first "automatic" registry cleaner I used 15 years ago did severe damage to my machine. Windows became unbootable because of registry damage. I ended up having to re-install Windows from scratch.
    PC Cleaner should not have disabled System Restore. If you haven't made any large installs or changes, System Restore simply may not have created a restore point. But there should have been at least the original when you installed Windows. To verify the settings, right click on "My Computer" and choose "Properties". There should be a System Restore tab where you can verify the allowed size and whether or not it is active.
    It is generally a good idea to manually tell System Restore to create a restore point on occasion, on a day when everything is working as it should.
    Is there a way to temporarily disable SparkTrust? It might be possible it sees the uninstall action as some kind of malware and won't allow it to run. That is simply a guess, but it is generally good policy to disable active security software during an installation (of trusted software), as the security software may interfere with the processes.
    I really don't believe Firefox is the culprit here. I think there is a problem with Windows. I have been using Firefox for well over a decade and have never had an uninstall problem.
    If you can copy and paste error details for the event log, I may be able to learn more.

  • Failed loading CD / DVD drives, error -43. Try doing a repair install on iTunes from the "Add or Remove Programs" control panel...

    I have done all the steps that I could find, and I am still having this issue...can someone help me please?
    Here is the diagnostics test I just ran as well. Not sure why it wont read my ipod either.
    Microsoft Windows Vista Home Basic Edition Service Pack 2 (Build 6002)
    Dell Inc. Inspiron 1525
    iTunes 11.1.5.5
    QuickTime not available
    FairPlay 2.5.16
    Apple Application Support 3.0.1
    iPod Updater Library 11.1f5
    CD Driver Not Available
    CD Driver DLL Not Available
    Apple Mobile Device 7.1.1.3
    Apple Mobile Device Driver 1.62.0.0
    Bonjour 3.0.0.10 (333.10)
    Gracenote SDK 1.9.6.502
    Gracenote MusicID 1.9.6.115
    Gracenote Submit 1.9.6.143
    Gracenote DSP 1.9.6.45
    iTunes Serial Number 00D5BEA809F38F28
    Current user is an administrator.
    The current local date and time is 2014-04-05 12:39:11.
    iTunes is not running in safe mode.
    WebKit accelerated compositing is enabled.
    HDCP is not supported.
    Core Media is supported.
    Video Display Information
    Intel Corporation, Mobile Intel(R) 965 Express Chipset Family
    Intel Corporation, Mobile Intel(R) 965 Express Chipset Family
    **** External Plug-ins Information ****
    No external plug-ins installed.
    **** Network Connectivity Tests ****
    Network Adapter Information
    Adapter Name:        {F45D6408-EDE8-4F4F-8BDF-AE815F918114}
    Description:            Dell Wireless 1505 Draft 802.11n WLAN Mini-Card
    IP Address:             192.168.0.16
    Subnet Mask:          255.255.255.0
    Default Gateway:    192.168.0.1
    DHCP Enabled:      Yes
    DHCP Server:         192.168.0.1
    Lease Obtained:     Sat Apr 05 12:21:08 2014
    Lease Expires:       Sat Apr 05 13:21:08 2014
    DNS Servers:         68.105.28.12
                                    68.105.29.12
                                    68.105.28.11
    Adapter Name:        {8F15FB4D-2EE6-4690-A8E7-82ACBF7A4F1E}
    Description:            Marvell Yukon 88E8040 PCI-E Fast Ethernet Controller
    IP Address:             0.0.0.0
    Subnet Mask:          0.0.0.0
    Default Gateway:    0.0.0.0
    DHCP Enabled:      Yes
    DHCP Server:        
    Lease Obtained:     Wed Dec 31 17:00:00 1969
    Lease Expires:       Wed Dec 31 17:00:00 1969
    DNS Servers:        
    Active Connection: LAN Connection
    Connected:             Yes
    Online:                    Yes
    Using Modem:        No
    Using LAN:             Yes
    Using Proxy:           No
    Firewall Information
    Windows Firewall is off.
    Connection attempt to Apple web site was successful.
    Connection attempt to browsing iTunes Store was successful.
    Connection attempt to purchasing from iTunes Store was successful.
    Connection attempt to iPhone activation server was successful.
    Connection attempt to firmware update server was successful.
    Connection attempt to Gracenote server was successful.
    Last successful iTunes Store access was 2014-04-05 12:38:45.
    **** CD/DVD Drive Tests ****
    LowerFilters: PxHelp20 (2.0.0.0),
    No drivers in UpperFilters.
    Failed loading CD / DVD drives, error -43. Try doing a repair install on iTunes from the “Add or Remove Programs” control panel.
    **** Device Connectivity Tests ****
    iPodService 11.1.5.5 is currently running.
    iTunesHelper 11.1.5.5 is currently running.
    Apple Mobile Device service 3.3.0.0 is currently running.
    Universal Serial Bus Controllers:
    Intel(R) ICH8 Family USB Universal Host Controller - 2830. Device is working properly.
    Intel(R) ICH8 Family USB Universal Host Controller - 2831. Device is working properly.
    Intel(R) ICH8 Family USB Universal Host Controller - 2832. Device is working properly.
    Intel(R) ICH8 Family USB Universal Host Controller - 2834. Device is working properly.
    Intel(R) ICH8 Family USB Universal Host Controller - 2835. Device is working properly.
    Intel(R) ICH8 Family USB2 Enhanced Host Controller - 2836. Device is working properly.
    Intel(R) ICH8 Family USB2 Enhanced Host Controller - 283A. Device is working properly.
    FireWire (IEEE 1394) Host Controllers:
    RICOH OHCI Compliant IEEE 1394 Host Controller. Device is working properly.
    Most Recent Devices Not Currently Connected:
    iPod touch (4th generation) running firmware version 6.0.1
    Serial Number:       CCQH8BRSDT77
    **** Device Sync Tests ****
    No iPod, iPhone, or iPad found.

    CD Driver Not Available
    CD Driver DLL Not Available
    With that one, I'd start with solution 3 from the following document:
    iTunes for Windows: Optical drive is no longer recognized, or "Disc burner or software not found" alert after install

  • Can't add or remove programs from dock

    I suddenly have a problem where I can't add or remove programs from the dock.  When I try to drag a program icon to the dock it won't stick to it and shows a "+" next to it in green.  When I try to drag an icon off the dock it shows a shadow of the icon that won't go away.  I tried making a new user and the same behavior occurs in that user.  I tried finding my com.apple.dock.plist but couldn't locate it.  I was able to find com.apple.dockfixup.plist and tried deleting that but it didn't help.  Any recommendations on where to go next?
    Thanks

    Thanks, I will try this when I get home today.  However, the fact that the problem was not corrected when I made a new user makes me think that deleting this file from my user Library folder may not correct the problem.  Any other suggestions if deleting the dock.plist file doesn't work?

  • How do you add and remove links to websites in folders on Safari?

    How do you add and remove links to websites in folders on Safari?

    For clarification, works like a bookmark of website only it is listed in toolbar with "Most Visited", "Latest Headlines", "News", and "Popular".  I have done it before but can't find it for the life of me.
    Thanks!

  • Need to Add and Remove Columns of ADF Read Only table from Backing bean

    I have a scenario where I am trying to Populate TransientVO which is shown has a ADF Read Only Table in page.
    I have couple of Check Boxes Based on their selection I am trying to render and hide certain Columns.
    But the Issue which I am facing is only the Column Header seems to change where as the Rows and Values doesnt..
    even If I apply the expression language rendering condition on the outputText inside those columns.. ..
    So I am thinking to add and remove VO Attribute columns to the table from backing bean.
    Need some sample code snippet or a better design to achieve this. Its kind of urgent too...having an aggressive deadline :(
    Please chip in People..
    Thanks in Advance .
    TK

    Table Code..
    <af:table value="#{bindings.InventoryGridTrans.collectionModel}"
                                    var="row"
                                    rows="#{bindings.InventoryGridTrans.rangeSize}"
                                    emptyText="#{bindings.InventoryGridTrans.viewable ? 'No data to display.' : 'Access Denied.'}"
                                    fetchSize="#{bindings.InventoryGridTrans.rangeSize}"
                                    rowBandingInterval="0" id="t4"
                                    partialTriggers="::sbcSales ::sbcUsage ::cb1">
                            <af:column sortProperty="Period" sortable="false"
                                       headerText="#{bindings.InventoryGridTrans.hints.Period.label}"
                                       id="c38">
                              <af:outputText value="#{row.Period}" id="ot33"/>
                            </af:column>
                            <af:column sortProperty="Past12SalesCount"
                                       sortable="false"
                                       headerText="#{bindings.InventoryGridTrans.hints.Past12SalesCount.label}"
                                       id="c29"
                                       rendered="#{backingBeanScope.IndexPageBackingBean.onUsage != true and backingBeanScope.IndexPageBackingBean.onSales == true}">
                              <af:outputText value="#{row.Past12SalesCount}"
                                             id="ot40"
                                             rendered="#{backingBeanScope.IndexPageBackingBean.onUsage != true and backingBeanScope.IndexPageBackingBean.onSales == true}"
                                             visible="#{backingBeanScope.IndexPageBackingBean.onUsage != true and backingBeanScope.IndexPageBackingBean.onSales == true}">
                                <af:convertNumber groupingUsed="false"
                                                  pattern="#{bindings.InventoryGridTrans.hints.Past12SalesCount.format}"/>
                              </af:outputText>
                            </af:column>
                            <af:column sortProperty="Past12UsageCount"
                                       sortable="false"
                                       headerText="#{bindings.InventoryGridTrans.hints.Past12UsageCount.label}"
                                       id="c40"
                                       rendered="#{backingBeanScope.IndexPageBackingBean.onUsage == true and backingBeanScope.IndexPageBackingBean.onSales != true}"
                                       visible="#{backingBeanScope.IndexPageBackingBean.onUsage == true and backingBeanScope.IndexPageBackingBean.onSales != true}">
                              <af:outputText value="#{row.Past12UsageCount}"
                                             id="ot47"
                                             rendered="#{backingBeanScope.IndexPageBackingBean.onUsage == true and backingBeanScope.IndexPageBackingBean.onSales != true}"
                                             visible="#{backingBeanScope.IndexPageBackingBean.onUsage == true and backingBeanScope.IndexPageBackingBean.onSales != true}">
                                <af:convertNumber groupingUsed="false"
                                                  pattern="#{bindings.InventoryGridTrans.hints.Past12UsageCount.format}"/>
                              </af:outputText>
                            </af:column>
                            </af:column>
                    </af:table>

Maybe you are looking for

  • Validation at Document Type level

    Dear Seniors, We have a requirement to have a validation for posing various documents by different users. Document type  JV should be posted by only a set of users USERS1. Document type GB should be posted by only a set of users USERS2. Document type

  • BT Mobile showing as Vodafone, voicemail button not working

    Anyone managed to get a BT Mobile sim working fully with an iPhone? Mine is showing as Vodafone - not an issue it itself - but I've had to enter the 3G data details manually, plus the Voicemail button in the Phone app calls the Vodafone one rather th

  • I cant access icloud setting, facetime or icould mail on my ipad after iso6 update

    After updating my ipad, I no loner have my Icloud E-mail, facetime or Icloud settings.  When I go to settings they are all grayed out.  I try to choose them but nothing happenes.when I try facetime, it says my Ipad is not authorized to use facetime.

  • Is there a Terminal command that will pick up DNS numbers?

    Hello all, Is there a Terminal command that will pick up the DNS numbers utilized by a router? The router options don't show any, though the router is set to use PPPoA to pick them up. I kindly TIA, Eme '~[ )♥♪

  • Menus switching, hanging sounds etc.

    I think my poor mac has been infected with a malware of some kind. When I click the apple icon in the top left, the menus start moving to the right untill it reaches the end, then starts over. It is impossible to click the choice I want. When I click