Removing element from vector

I am trying to remove an element from a Vector and using the ff code:
Vector abc = getVector();
int index = 0;
abc.removeElementAt(index);
The element is not being removed, when i go back to check the number
of elements in the vector, it is still the same.
Please give me any ideas to make this work.

Try this,
Vector abc = getVector();
int index = 0;
System.out.println("Size before : "+abc.size());
abc.remove(index);
System.out.println("Size after : "+abc.size());
What is the o/p?
Sudha

Similar Messages

  • Remove element from xml using dom.

    i want to remove an element from an xml file using dom.
    i remove the element but the whole content of the file is also deleted.
    how can i rewrite the file.

    vij_ay wrote:
    subject :Remove element from xml,but if empty element in input file then output should be <tag></tag>, not like <tag.xml/>I assume you mean <tag/> but why do you want this? Any application that will not accept this valid XML construct is flawed and a bug report should be raised against it.

  • Strange problem with removing element from node

    Hi,
    I have a problem when I removed elements from a node.
    here is the code:
    String text = "123456";
    IANode nodeA= wdContext.nodeA();
    wdContext.nodeB().invalidate();
    IBNode nodeB = wdContext.nodeB();
    for(int i=0; i<nodeA.size(); i++)
    IAElement e = nodeA.getEt_Emp_RespElementAt(i);
    if (e.getID().compareTo(text)!= 0)
         nodeB.removeElement(e);
    else
    wdComponentAPI.getMessageManager().reportSuccess(e.getID() + " was not removed");
    The node A does have a row with field "ID" equals to 123456.
    When running the application, it does write that "123456" was not removed...but it removes it....In fact my table is now empty.
    How is it possible if it didn't perform the remove operation for ID = 123456 ?
    Thanks in advance.

    David,
    Because you are iterating node in wrong direction: see my reply to your post Re: Loop problem (seems that you assigns me 2 points without reading reply, and mark it as solved just because you stop solving it
    So, in example in this thread, you must iterate node B in reverse direction, get element from B and remove it from B if it has some specific ID.
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com

  • Emergency!! How to remove elements from a set? or..?

    How do I remove elements from a Set?
    If I have Set s1and s2, I want to create a new set which consist of all elements in s1 but not in the s2.
    Which means, I have to s1.union(s2) and then remove elements of s2.
    Is there any method which has this function (remove elment from a set)?
    Or is there any other better way to solve this (which doesn't have to remove anything)?
    If not, how to design a method which will do this job?
    Your help will be very much appreciated.

    Hi
    you can use method removeAll() from set
    s1.removeAll(s2);
    so s1 contains all the element not in s2.
    If you want to lef s1 unmodifyed you have to create a copy.
    Set s3 = s1.clone();
    s3.ramoveAll(s2);
    bye
    Nicola.

  • Is there a way to remove elements from an array 1 by 1?

    I have an two arrays, and they vary in size depending on a parameter set by the user (both arrays are the same size though, they both can vary in length). What I need to do, is remove elements one by one from the array, and use these as indices for another array. Basically, I built two arrays to store x-values on a graph. At the first value on the first array, I want y values on the graph to move from 0 to Y (any value). Then on the first value on the second array, I want the y values to move back from Y to 0 (creating a pulse, essentially, from the first value on the first array and the first value on the second array). By having each x value act as an indice for the y array, I belive I can acc
    omplish this (ie, y =0 up to indice 90, then y = 5, then at indice 100, y goes back to equaling 0). I know this is poorly phrased, but it's difficult to explain. If anyone could help me out, I'd really appreciate it.

    jdaltonnal,
    Note: to add an attachment based on your comment of 6/12/01 to my earlier reply, I had to go back to this 'answer' mode, which gives me the option of adding attachments.
    Per your comment, you have a sequence, so I've added a simple sequence structure and the 2nd array to provide a 250ms delay between each array output. Let me know...Doug
    Attachments:
    arrayindexplus1withseqdelays.vi ‏27 KB

  • Remove element from multi-surface

    Hi there,
    I am trying to fix some invalid multi-surface geometries that are derived from a 3D source, many of which have ORA-54514: overlapping areas in multipolygon.  I can find out which subset geometry (aka the element in this context) is causing the problem with the VALIDATE_GEOMETRY_WITH_CONTEXT function, and even extract just that element (SDO_UTIL.EXTRACT3D), but how do I remove that element from the geometry (and hopefully fix the problem)?  Is there any way to view the position of the element within the geometry in the same manner that the Extract3D function requires (i.e. 0,0,1,1,0,0,7), I can return this for the problem element but not for any of the other subset geometries.  Unfortunately I'm using FME to load the geometries and the topology validation here is not as robust as Oracle, which means I need to fix the geometries once they are loaded, but there doesn't seem to be any tools to do this?
    Regards
    Dan

    Hi Dan,
    instead of removing the offending element, how about extracting all the correct ones? Should give the same net effect, I think.
    Re FME: I find I can usually validate geometry enough that it will at least pass Oracle's Validate, but that's usually only 2D or 2D with a Z-ordinate (2.5D, as some folks call it).
    Regards,
    Stefan

  • Remove element from arraylist, jstl

    HI there,
    i use bean for an array list
    <jsp:useBean id="list" scope="page" class="java.util.ArrayList"/>
    then i add element in the list
    later i need set up a loop does the following:
    remove one element from the list and process it
    until the list is empty
    is this (romoving elment from a list) possible to be done using only jstl
    thanks

    No, it is not possible.
    JSTL is for use on JSP pages.
    JSP pages are meant for "display"
    You sound like you are doing processing - this sort of stuff more properly belongs in a java class.

  • Problem when removing elements from table after apply sort

    Hi,
    I have big problem with <af:table> and sorting.
    When I removed objects from a table without sorting, there is no problem but when I removed
    items from the table after sorting, the remain items are not correct.
    For example, i have in my table these items :
    Item AA
    Item CC
    Item ZZ
    Item BB
    Item AA
    Item BB
    Item CC
    Item ZZ
    I sort the table and i select the following Items : Item BB a Item CC
    The remains item is only Item AA, Item ZZ disappear.
    If i resort the table, the missing Item zz appear again in the table.
    Here is my jspx :
    <af:table var="row" rowBandingInterval="1" width="1050" rows="5"
    rowSelection="multiple"
    value="#{pageFlowScope.editNotificationBackingBean.ingredients}"
    binding="#{pageFlowScope.editNotificationBackingBean.ingredientsTable}"
    autoHeightRows="10" id="t2">
    <af:clientListener method="goEditRow" type="dblClick"/>
    <af:serverListener type="doubleClickOnRow" method="#{pageFlowScope.editNotificationBackingBean.handleRequestIngredientsSelectBtn_action}"/>
    <af:column headerText="#{bundle.col_fr_name}" width="240"
    sortable="true" sortProperty="name.FR_Description" id="c1">
    <af:outputText value="#{row.name.texts['fr'].value}" id="ot1"/>
    </af:column>
    In my backing bean i call this method to remove selected elements :
    public void unselectBtn_action(ActionEvent actionEvent) {
    RowKeySet rowKeySet = selectIngredientsTable.getSelectedRowKeys();
    int i = 0;
    Iterator it = rowKeySet.iterator();
    while (it.hasNext()) {
         Integer index = (Integer)it.next() - i;
    selectIngredientsTable.setRowKey(index);
    CompositionIngredient compositionIngredient =
    (CompositionIngredient)selectIngredientsTable.getRowData();
    notification.getProductDetail().getCompositionIngredients().remove(compositionIngredient);
    i++;
    selectIngredientsTable.getSelectedRowKeys().clear();
    AdfFacesContext.getCurrentInstance().addPartialTarget(selectIngredientsTable);
    Thanks in advance.

    I have made a mistake, i don't paste the right <af:table> from my jspx.
    Here is the correct one :
    <af:table var="row" rowBandingInterval="1" width="1050"
    rowSelection="multiple" id="tableSelectedIngredients"
    value="#{pageFlowScope.editNotificationBackingBean.notification.productDetail.compositionIngredients}"
    binding="#{pageFlowScope.editNotificationBackingBean.selectIngredientsTable}"
    partialTriggers="::tab_ingredients_list_expressed_per">
    <af:column sortable="true" headerText="#{bundle.col_name}" id="c5" width="180"
    sortProperty="ingredient.name.FR_Description">
    <af:outputText value="#{row.ingredient.name.texts['fr'].value}"
    id="ot18"/>
    </af:column>
    ...

  • Remove element from GUI

    Hi guys,
    I am adding elements to the gui like this:
    var myText = win.add("edittext", undefined, "whatever");
    Later in my code I need to remove this element from UI. Is it possible?

    Use the remove() method: win.remove(myText);
    In general: container.remove(child);
    You can add it later later but then, if you use the autolayout, you'll need to relayout: win.layout.layout(true) otherwise it won't show up

  • URGENT: Removing element from a vector?

    ok I have a text database where the lines look something like this:
    5876,Tigger,50.00
    7892,Piglet,25.00
    my problem is I have to remove an element that I don't know the index of, so I figured I have to search the vector for the number(eg, 5876) and return the index so I can remove it, but I don't know how to do this. Please help me

    Try this:
    public class Parser
    public Vector read(InputStream in) throws IOException
       Vector structures = new Vector();
       StringBuffer buffer = new StringBuffer(128);
       int n = -1;
       while((n = in.read()) != -1)
          char c = (char)n;
          if(c == '\n')
             structures.add(getDataStructure(buffer.toString()));
             buffer.delete(0, buffer.length());
          } else
             buffer.append(c);
       if(buffer.length() > 0)
          structures.add(getDataStructure(buffer.toString()));
       return structures;
    protected DataStructure getDataStructure(String string)
       DataStructure structure = new DataStructure();
       StringTokenizer st = new StringTokenizer(string, String.valueOf(','));
       structure.id = (String)st.nextElement();
       structure.name = (String)st.nextElement();
       structure.price = Float.parseFloat((String)st.nextElement());
       return structure;
    public class DataStructure
       String id;
       String name;
       float price;
       public DataStructure() {}
       public boolean equals(Object o)
          if(o instanceof DataStructure)
             return id.equals(((DataStructure)o).id);
          } else if(o instanceof String)
             return id.equals((String)id);
          return false;
    }Now you can keep track of the info in a better way.
    If you have
    5876,Tigger,50.00
    5876,Tigger,50.00
    5876,Tigger,50.00
    5876,Tigger,50.00
    5876,Tigger,50.00
    Stored in a file, you can do this:
    Vector v = new Parser().read(new FileInputStream("..."));
    Structure s = (Structure)v.elementAt(0);
    System.out.println(s.name);
    v.remove("5876");Isn't that nice?
    Note that the code may or may not compile.
    Hope it helps,
    Nille

  • Remove element from array

    hi
    if i have an array
    eg
    int[] array = {4,2,1,2,1};
    how to i remove the index 2 from it and create a new array?
    thanks

    You can't remove the element--an array's size is fixed at creation.
    If you want a new array, create a new one that's one element smaller, then use System.arrayCopy to copy the elements you want to keep.

  • How to remove element from ByteArrayOutputStream ?

    hello frds,
    some body please help me how to remove first two elements of ByteArrayOutputStream before converting it to byte[]
    if not possible,please help me out in deleting two elements of byte[] without using arraycopy method
    thanks

    instead of writing and then removing these 2
    elements, isn't it just more logical to not write
    them in?and if you can't do that (e.g. because the code writing into the OutputStream is not under your control), then you might consider writing a decorator e.g. called "DroppingOutputStream" extending java.io.FilterOutputStream which forwards all data to the underlying stream except for the first two bytes.

  • Extraction elements from vector

       Hi everybody, 
     Can anybody help with this problem, pls  Im a begginer with labview  I would like solve a problem: There is  matrix (2048x1 elements) and I would draw it point by point in wafeform chart, I have already tried everything,  but I have  allways drawn the whole vector.
     Sorry for so stupid question......
       best regards
    thx  tomas

    Not stupid, but it is resolved.
    http://forums.ni.com/t5/LabVIEW/Graph-an-Array-but​-not-every-row-of-it/td-p/1188601
    Mahu

  • I talked with Adobe Yesterday about removing Elements from my Mac, if there were any concerns with Lightroom 5 and Photoshop CS6

    The answered no, that all I needed to do with Elements was to drag it to the Trash. I did that. Now in Lightroom 5 do I not see Photoshop in the EDIT IN menu, all my plug-is are missing as well! Ive found two papers on the subject, one for both programs where they say to find the Lightroom fine "com.adobe.Lightroom5.plist" and a similar Photoshop fine in >user>Library>Preferences. Neither exist on my mac! Im in a process of a system search to make sure, but so far, no good!
    I'm looking for a fix, PLEASE. To stop and delete both programs, reinstall this and ALL the plug-in's isn't something I want to contemplate if I don't have to!

    Sorry Keith, I didn't look at it as a duplicate post since I initually approached it as a Photoshop issue and have since come to see it as a lightroom issue. I've subedquently found the photoshop preference file, deleted it and restarted Photoshop which recreated that file. That didn't help.
    SInce my initial concern was with Photoshop I failed to notice than none of the Lightroom plug ins were showing up. Researching that fix, what I found was essentially the same as with Photishop except the Lightroom preference file. Now I'm not finding that file but I'm doing a full system search.
    Some caveats to all of this are, the photoshop and Lightroom plug ins are the same. Theyre resident and run in CS6. Additionally in Lightroom if I go to preferances> external edit, I see photoshop and all the plug ins listed there.

  • Add or remove elements from a list attached to session duplicated the size

    Hi All,
    I have a jsp page that in there I'd like to show three columns in a table:
         <c:forEach var="thesaurus" items="${sessionScope.collection.thesaurusList}">
           <tr>
                        <td class="check"><input type="checkbox" name="word" value="${thesaurus.key}" ></td>
                        <td><c:out value="${thesaurus.key}"></c:out></td>
                        <td>${ts:getThesuaursRelationDescription(thesaurus.relation)}</td>
                        <td>${ts:getThesaurusSynonymsDescription(thesaurus.synonymsList)}</td>
              </tr>
           </c:forEach>thesuaurList is an ArrayList that holds object of type Thesaurus class ( a simple java bean). collection object is attached to session via a servlet.
    ts are tag that i have defined in my tag library.getThesuaursRelationDescription and getThesaurusSynonymsDescription are two static method and there's no problem with any of these classes.
    It all works ok but when I refresh the page, the list size gets duplicated each time and i can't see why? why items are added again to my list? Is that because i have collection object as an session attribute?
    If i replace the above code with jsp scriptlet it works fine:
    <%
                    Collection collection = (Collection) session.getAttribute("collection");
                    List< Thesaurus> thesauruses= collection.getThesaursList();
                    int i = 0;
                    for (Thesaurus thesaurus: thesauruses)
                    %>
                     <tr>
                        <td class="check"><input type="checkbox" name="word" value=<%=thesaurus.getKey()  %> ></td>
                        <td><%=thesaurus.getKey()%></td>
                        <td><%=ThesaurusUtil.getThesuaursRelationDescription(thesaurus.getRelation())%></td>
                        <td><%=ThesaurusUtil.getThesaurusSynonymsDescription(thesaurus.getSynonymsList())%></td>
                    </tr>
                    <%
                    %>Thanks in advance.

    Gr8 not a problem why do you use a composite view pattern.
    --->In that case make use of Proper patterns in your design before forwading it to a view.
    ---->Use a Public JSP Statically include JSP's in WEB-INF folder using static page include which happens at compile time.
    REGARDS,
    RaHuL

Maybe you are looking for