ArrayList question. How to remove an Item

I have an array collection that is going to contain a list of username.
I would like to fine one of the names and remove it from a list. How could I do this.
I am an Actionscript programmer so if I where to do this in AS I would do it like this.
for(var i:int=0; i<myarray.length; i++)
      if(myarray[i] == "matthew")
      myarray.remove(i);
}in Java I am not seeing a length property for the ArrayList

7biscuits wrote:
ArrayList al = new ArrayList();
al.add("aa");
al.add("ab");
al.add("ac");
al.add("ad");
for(int i=0; i<al.size(); i++){
if(al.get(i)=="ac"){
al.remove(i);
}here "ac" is removed from the arraylistAll I can do is shake my head and chuckle (and sigh).
Don't use == to compare Strings, and did you not read the rest of the thread that said it is not necessary to use the index? Not to mention, to either you or the OP, that 2 seconds of looking at the API docs would have let the both of you come to that same conclusion.
Also, if you do remove items in an ArrayList in this manner (for whatever reason) then loop through the ArrayList backwards, or you will skip an element every time you remove one.
Too little, too late, and so off target.

Similar Messages

  • How to remove an item from side bar?

    Can anyone teach me how to remove following item  from side bar:    Thank you!

    Niel thank you very much for you help.

  • How to remove particular item in array

    hai friends,
    how to remove particular item in array

    use splice() method
    http://livedocs.adobe.com/flex/3/langref/Array.html#splice%28%29

  • How to remove these items from Infopath ribbon in web enable form?

    Hi All,
    I am using custom list form customized in infopath 2013, I want to remove these items from ribbon :
    I tried with Infopath  "form Options" like:
    But still showing "Picture-1" options. How to remove those items from ribbob?

    Hi,
    I understand that in the list view web part, you wanted to remove the ribbon of InfoPath form.
    There are to mothed to achieve it:
    Open the list, click new item, edit page, edit web part, unclick the ‘Show InfoPath Ribbon or toolbar’ box, the new item page will remove the riibon.  Then when you open the page which has the list view web part, the ribbon of InfoPath form will also
    be removed.
    Open the page which has the list view web part, edit page, edit the list view web part, unclick the ‘Show InfoPath Ribbon or toolbar’ box, the ribbon of InfoPath form in the web part will be removed. Then when you open the list, the ribbon of InfoPath form
    will also be removed.
    The two method edit the same page newifs.aspx, so the list and the webpart will be modified in the same time.
    Thank you for your understanding.
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to remove the item content from my alert Template (alerttemplates.xml) .

    I have enabled alerts to be send from my enterprise wiki & announcement list. Currently the alert email, will display the item content inside the email (the wiki page content or the announcement list content), which i do not want to have. So is
    there a way to remove the item content , so my alert message contains only the following info such as:-
    Our Group Intranet
    TestItem has been added
    Modify my alert settings
    |
    View TestItem
    |
    View News & Announcements
    |
    Mobile View

    Hi johnjohn123,
    According to your description, my understanding is that you want to change the notification message in the alert template.
    You can edit the ImmediateNotificationExcludedFields and DigestNotificationExcludedFields tags to achieve it. After editing the xml, remember apply the template
    to your site using the command below.
    execute command stsadm -o updatealerttemplates -filename <your modified xml file> -url <your site>
    Also, It is not suggested to edit the alert template directly, I suggest you back up the template firstly before customization.
    More information:
    How to change alert email notification message:
    http://dirkvandenberghe.com/2008/01/08/how-to-change-the-alert-email-notification-message-for-announcements.html
    AlertTemplates schema:
    http://msdn.microsoft.com/en-us/library/office/bb802961(v=office.15).aspx
    Best regards,
    Zhengyu Guo
    Zhengyu Guo
    TechNet Community Support

  • How to remove all item in JPanel???

    How to effectively remove all item before add new item and display new panel??? I only know
    p1.setLayout(null);But seems like my JButton still there....Please advice

    As we dunno what the item in the panel, we just want to clear all item in panel. Because the clear panel in action listener, it perform clear the previous panel before display new panel.
    Please advice

  • How to remove the item in Did.View .

    Hi,
    How to remove the Work sheet item in Dis.viewer.By using drill to related u can add the item into the worksheet.i want to remove the same...
    Regards
    Manikandan.

    Hi Manikandan
    Just use the back button on the browser. The page will return to the original query. That's the whole point of why Viewer is based on HTML.
    Bets wishes
    Michael

  • How to remove an item in a folder in Reminders on the IMAC

    I am trying to remove an item in a folder in Reminders on my IMAC.  I tried holding down the control key and clicking on the item.  Sometimes I get a pop up menu with the "delete" option.  But more often than none when I do this I get a pop up menu to cut, copy etc...not to delete.  Why the inconsistencies in holding down the control key and clicking the mouse?  Is there another way to remove the item listed in the folder?
    Thank you for your help.

    Hi ly_he,
    You have posted the same thread in the chinese forum of WPF, and I have replied. You could see here:
    https://social.msdn.microsoft.com/Forums/zh-CN/029bccae-f2f0-4218-980b-2389da8e5d2c/mvvm-wpf-treeview?forum=wpfzhchs
    Best Regards,
    Xavier Eoro
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • [Question] How to remove baby blue text chat bubbl...

    My Skype for Windows (windows 7), just updated to the latest version 6.22.0.107. With this update Skype has completely changed the look and feel of the entire interface giving it a light blue overlay on everything.
    I was wondering if there is any way to remove the light blue chat bubbles that now show up surrounding all text messages sent or received?
    I would prefer the old simple black and white standard text message layout of the previous version of skype. I find that the light blue bothers my vision and makes it more difficult for me to read my messages and follow the conversation.
    Thanks for any help with this issue.

    How to remove them:
    http://download.skype.com/msi/SkypeSetup_6.21.0.104.msi
    The Skype design will as all other designs evolve. Look at for instance MS office, the 2003 version looks nothing like the 2007 one and beyond. Reasons for this; ribbons made people more productive (according to designers).
    The design quirk now, is devices, all for now 3 of them phones, pads, and Computers. Crossplattform design is not an easy task, and will offcourse cause design changes.
    That said, chat bubbles and the like are a new Skype thing, is it good, we don't know yet. When I had my old Nokia phone, I laughted off the iBubbles, now I'm om Android, and used to them.
    Would I prefer the old msg style? Yes, most likely, but I do manage to have fun in the new one (phone).

  • Question: How to remove prompt in recording using MMAPI

    Hi,
    we have been developing a softphone using j2me. Our goal is to record voice (using j2me) into a byte array and deliver that as a packet either through bluetooth or wifi. We need to capture voice at a certain interval, stop the capture, deliver, and then capture the voice again.
    The problem is this. Everytime i call on record, the phone prompts if i indeed want to record using the MMAPI. I think that this is a security feature but is there any way to bypass it?
    --Kyle                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    private bool RemoveBlankPage()
            Word.Application wordapp
    = null;
            Word.Document doc
    = null;
            Word.Paragraphs paragraphs=null;
            try
                // Start Word APllication and set it be invisible
                wordapp
    = new Word.Application();
                wordapp.Visible
    = false;
                doc = wordapp.Documents.Open(wordPath);
                paragraphs
    = doc.Paragraphs;
                foreach
    (Word.Paragraph paragraph
    in paragraphs)
    if (paragraph.Range.Text.Trim()
    == string.Empty)
                        paragraph.Range.Select();
                        wordapp.Selection.Delete();
                // Save the document and close document
                doc.Save();
                ((Word._Document)doc).Close();
                // Quit the word application
                ((Word._Application)wordapp).Quit();
            catch(Exception ex)
                MessageBox.Show("Exception Occur, error message is: "+ex.Message);
                return
    false;
            finally
                // Clean up the unmanaged Word COM resources by explicitly
                // call Marshal.FinalReleaseComObject on all accessor objects
                if
    (paragraphs != null)
    Marshal.FinalReleaseComObject(paragraphs);
                    paragraphs
    = null;
                if
    (doc != null)
    Marshal.FinalReleaseComObject(doc);
                    doc
    = null;
                if
    (wordapp != null)
    Marshal.FinalReleaseComObject(wordapp);
                    wordapp
    = null;
            return
    true;
     This link helped me complete my project
    https://code.msdn.microsoft.com/office/How-to-remove-blank-pages-e200755d

  • Question: How to remove accidental Icons

    I was selecting Email the other day and accidently dragged it from my launcher bar into the app area.  Now I can't get rid of it at all from any of the app screens.  I certainly don't need 2 links for Email.  Anyone know how to remove it without deleting the Email app alltogether?
    Post relates to: Pre p100eww (Sprint)

    Pressing on the Orange button and tapping on the Icon you want to remove will ask you to delete. This only works for links, contacts, and applications you installed. 

  • URGENT: How to remove an Item from HTMLB listbox

    Hi All,
    I am designing a page, which contains a listbox, whose contents(items) need to be changed dynamically.
    I can populate it dynamically using
                   listbox.addItem(key, string)
    But, i don't see any specific methods to remove an item from it.
    Please Help Me in this Regard..
    vijay

    Hi Vijay,
    (a) every request on SDN is expected as urgent... If you won't use this word in the future, you'll have more time for solving your problems
    (b) If your listbox.getModel() returns the DefaultListModel, you can call removeItem(String key) on the model; see http://media.sdn.sap.com/javadocs/preNW04/SP2/60_sp2_javadocs/htmlb/com/sapportals/htmlb/DefaultListModel.html#removeItem(java.lang.String) for details
    Hope it helps
    Detlev
    PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

  • ComboBox Item How to remove repeating items that came from an entity of a .dbf database

    Hi all,
    Can somebody help me? What  I want to happen is create a ComboBox Item from a .dbf database, the PMXMON contains each product's monthly data. Here's a screenshot of the output:
    Is there a way to remove repeating items without changing the database contents?
    I have this code:
    Private Sub frmYearMonth_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim conn As New System.Data.Odbc.OdbcConnection("Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=C:\;Exclusive=No")
    conn.Open()
    Dim strQuery As String = "SELECT * FROM CSHPMXP1"
    Dim adapter As New System.Data.Odbc.OdbcDataAdapter(strQuery, conn)
    Dim ds As New System.Data.DataSet()
    adapter.Fill(ds, "PMXMON")
    With ComboBox1
    .DataSource = ds.Tables("PMXMON")
    .DisplayMember = "PMXMON"
    .ValueMember = "PMXMON"
    .SelectedIndex = 0
    .Text = "--YYYYmm--"
    End With
    End Sub
    Thanks :)
    Geee

    You can use Distinct keyword to return unique records from your DB.
    On the side  I'm not seeing any informative value in your Comobox, if you trying to show product monthly data.
    SELECT Distinct PMXMON
    FROM CSHPMXP1
    Fouad Roumieh

  • How to remove suppressed items in the group tree from the crystal report print preview screen

    I am removing items in report using group selection formula. Although the removed items are not available in the report, they are still available in the group navigation tree on the left pane. Is there a way to overcome this ?

    Hi All,
    How can i use the below group selection code in record selection.
    TotalQuantity := sum({ICIVAL.QUANTITY},{ICIVAL.ITEMNO});
    TotalCost := sum({ICIVAL.TRANSCOST},{ICIVAL.ITEMNO});
    iIncludeQty := TONUMBER({?INCLUDEQTY});
    iIncludeCost := TONUMBER({?INCLUDECOST});
    bIncludeQty := FALSE;
    bIncludeCost := FALSE;
    SELECT iIncludeQty
        CASE 0:
            bIncludeQty := TRUE
        CASE 1:
            If TotalQuantity > 0 THEN
                bIncludeQty := TRUE
        CASE 2:
            If TotalQuantity = 0 Then
                bIncludeQty := TRUE
        CASE 3:
            If TotalQuantity < 0 THEN
                bIncludeQty := TRUE
        CASE 4:
            If TotalQuantity <> 0 THEN
                bIncludeQty := TRUE
    SELECT iIncludeCost
        CASE 0:
            bIncludeCost := TRUE
        CASE 1:
            If TotalCost > 0 THEN
                bIncludeCost := TRUE
        CASE 2:
            If TotalCost = 0 Then
                bIncludeCost := TRUE
        CASE 3:
            If TotalCost < 0 THEN
                bIncludeCost := TRUE
        CASE 4:
            If TotalCost <> 0 THEN
                bIncludeCost := TRUE
    bIncludeQty AND bIncludeCost

  • How to remove an item from one of the tabs?

    How can one remove one of the items from a tab in SAP portal? Here, I'd like to remove the 'Change Order' under Time Administration.

    Hi Sean,
    Right click on the role, choose Open -> Role.
    Find and select "CHANGE ORDER" iview in the role content.
    You can now either delete it from the role or just prevent from being displayed
    Click Open.
    Click Properties, then click on All.
    Find property called "Invisible in Navigation Areas" and set it to Yes.
    Please be aware that clearing navigation cache might be needed for changes to become visible.

Maybe you are looking for

  • How can i make a Web application with listboxes as the column value

    Hi, I have two tables,one is employeees the other is devices.(Devices is the table for department notebooks).I want to implement an applicatiion for employees in order for them to book department laptops,so everyone will know which devices are in use

  • J_security_check ques ???

    Hi , I'm trying to transplant my working test platform on winNT onto hp/ux 10.20. I've now got to the point where I have the url http://www.xxx.xxx/uni/course/login.jsp. When I enter some data, instead of the authentication happening, the same side n

  • New computer, new iTunes?

    I bought a new computer recently. I currently have iTunes 6.0.5.20 on my laptop, but I want to move it to my new system. The problem I suspect is that the CD that came with my 30G iPod is likely an older version (of 6.0, but still, older). If I insta

  • Writing text with NXT icon

    Hi Using LabView 2010 I tried to write text in certain x,y position and not in line. I could not find an equivalent Icon to do the job, Needed to use the NXT_DisplayText from the remote vi library (see attached picture) The Vis from the remote librar

  • Will Adobe Photoshop Elements 10 and Premiere Elements 10 work on Windows 8.1

    Will Adobe Photoshop Elements 10 and Premiere Elements 10 work on Windows 8.1