Remove same elements in list

Hi all, I have a list which has similar items like (A,B,B,C,A,B,D).... How will I make the list as (A,B,C,D)...
Any help appreciated...

cflib.org has a function called ListGetDistinctValues.  That looks promising.

Similar Messages

  • Removing specific element from a list

    Hello, I'm very new to java, and to programming in general.
    I'm trying to write a secret santa app for my family for christmas. Essentially the idea is that 7 names are put into a list, and each time a name is "pulled" (i.e. randomly assigned to a name /= itself) it will be removed from the list of available names to assign.
    String[] nList = { name2, name3, name4, name5, name6, name7 }; // store names for random use
    Random r = new Random();
    name1assign = nList[r.nextInt(nList.length)];
    String[] nList2 = { name1, name3, name4, name5, name6, name7 };
    name2assign = nList2[r.nextInt(nList2.length)];
    My goal for this is to take the string that is equal to name1assign, and remove an element with that string from nList2.
    Can anyone give me some advice in this matter?
    Thanks.

    Sometimes a null value is used to indicate an 'empty' array element, but it would be better to try collections instead.
    You could use an ArrayList instead of an array. This has methods to remove items by index or value.
    An ArrayList also works with Collections.shuffle, which allows you to simply iterate over the list and not deal with random or removing elements at all.

  • Ho to remove duplicate element in the List ?

    It seem to be very basic, but it not working, even I try different way.
    This my List [10, 10, 11, 11, 12, 12, 13, 13, 14, 14],
    now to remove duplicate elements to have at the end [10, 11, 12, 13, 14]
    my code seem to be perfect but...
    for(int i = 0; i < listA.size(); i++){
         if(i%2 == 0){
              System.out.println("ce i est un nombre pair "+i);
              listA.remove(i);
    System.out.println(listA);

    senore100 wrote:
    The problem is that every single time an element is removed, the whole ArrayList is re-shuffled, with all the elements to the right moved to the left on spot. That's why.Yes, that's right. However if you had used an Iterator over the list, you could easily have removed every other element. It's only when you use an array index that you run into this (very common) problem.

  • Trouble removing some elements of a TreeSet/SortedSet

    I've been stuck with this for quite a while, having been able to work around it, but now it's really getting annoying.
    I'm using a TreeSet (using a SortedSet to have it synchronized) containing a list of nodes. Each node has a priority value, which is used as a key to sort the set.
    I can use this successfully but after some time, when I want to remove a certain node, the call to remove doesn't succeed in removing the element from the set, the element is still in the set after the call. I checked my comparator manytimes, and everything seems to work fine there, I tracked the call and although my node is in the set, when the comparator is called, all the elements of the set don't seem to be tested, and the actual position of the node in the set "ignored" as several other elements.
    in fact, I use two TreeSets, but they aren't not using the same comparator, so I don't think I have a conflit in there.
    here is a very light version of the node class and the comparators (won't run, but give you an idea of what I'm doing)
    Node Class
    public class Node {
         protected double priority1;
         protected double priority2;
         int nodeID;
    Comparators
    private class Comparator1 implements Comparator
      public int compare(Object o1, Object o2)
        Node t1 = (Node)o1;
        Node t2 = (Node)o2;
        if (t1.nodeID == t2.nodeID)
          return 0;
        int diff = (int) (PRIORITY_SAMPLING * (t1.priority1 - t2.priority1));
        if (diff == 0)
          return t1.nodeID - t2.nodeID;
        else
          return diff;
    private class Comparator2 implements Comparator
      public int compare(Object o1, Object o2)
        Node t1 = (Node)o1;
        Node t2 = (Node)o2;
        if (t1.nodeID == t2.nodeID)
          return 0;
        int diff = (int) (PRIORITY_SAMPLING * (t1.priority2 - t2.priority2));
        if (diff == 0)
          return t1.nodeID - t2.nodeID;
        else
          return diff;
    }at some point, I use the following code to access my sets and exploit their data, having various treatments and stuff
    maxPriority1Node = (Node) Queue1.last();
    minPriority2Node = (Node) Queue2.first();
    while (maxPriority1Node.priority1 > minPriority2Node.priority2)
      if (Count > desiredCount)
        minPriority2Node.merge();
      else
        maxPriority1Node.split();
        maxPriority1Node = (Node) Queue1.last();
        minPriority2Node = (Node) Queue2.first();
    }at some point, I'm in the case : Count > desiredCount so I call the merge part, which adds the current node to the Queue1 while removing it from Queue2, but the removal is never done, so the node is still present in Queue2. When I get back from the call, the minPriority2Node is still the same node because it's still in the list, and I end up stuck in an infinite loop.
    Can someone help me with this, or explain me what exactly happen when I try to remove the node from the set, which would explain why the node is still in the list after I tried to remove it ?
    if you need some more details to understand my problem, just ask, I'll try to give you more informations then.

    thanks for you help but, as you have guessed, merge and split do much more things than just dealing with the queues.
    But I've found where the problem was.
    I had wrongly assuming that the value returned by the comparator was used by the TreeSet, wether in fact, it's only the sign of it which is useful.
    In my code, I was using a constant called PRIORITY_SAMPLING, which was an arbitrary int (0xFFFFFF) to convert my double values (the double values could be any value, not just normalized 0.0 to 1.0 values, so I could not use a bigger int value). This constant was used to convert my double value to an int, trying to have enough precision to differenciate approaching value. In fact, the precision of this constant was not sufficient.
    now, I don't use the constant, which, in fact, was useless. Because what is important in the comparator result is not the value but the sign, so I can do a simple test between my double values and return -1 or 1.
    I had to had a special case for nodes whose priority are equal, so that they get sorted by ID, which is consistent over time.
    here are the new comparators :
    private class Comparator1 implements Comparator
         public int compare(Object o1, Object o2)
              Node t1 = (Node)o1;
              Node t2 = (Node)o2;
              if (t1.nodeID == t2.nodeID)
                   return 0;
              if (t1.priority1 == t2.priority1)
                   return t1.nodeID - t2.nodeID;
              else if (t1.priority1 < t2.priority1)
                   return -1;
              else
                   return 1;
    private class Comparator2 implements Comparator
         public int compare(Object o1, Object o2)
              Node t1 = (Node)o1;
              Node t2 = (Node)o2;
              if (t1.nodeID == t2.nodeID)
                   return 0;
              if (t1.priority2 == t2.priority2)
                   return t1.nodeID - t2.nodeID;
              else if (t1.priority2 < t2.priority2)
                   return -1;
              else
                   return 1;
    }

  • Thread FAQ:findind removed collection elements

    Hi All
    i have two threads and one collection with some elements ,The problem is one removed some elements in collections now i want to find out elements removed by thread one with thread two

    Well they're not in the collection any more, are they? so the thread that removed them will have to remember them somewhere, or else the other thread will need a copy of the original collection.
    It's not a Thread FAQ question. Any two classes that used the collection would have the same issue.

  • How to manually remove Photoshop Elements 4.0 from Windows

    My uninstaller for Photoshop Elements 4.0 in Add or Remove programs fails with the message - "This action is only valid for products that are currently installed." The program folder still resides on my harddrive. The program itself neither runs nor will it allow me to delete the program files' Photoshop Elements 4.0 folder that contains the executable and dll files from my harddrive. I need a manual uninstall proceedure.

    Have you got the disc? If so, you might try installing it again then an uninstall.
    Failing that...
    Here's the Adobe tech doc on removing Photoshop Elements 5. I would assume it would be the same procedure.
    http://kb2.adobe.com/cps/333/333201.html

  • Manually remove Premiere Elements 11

    I have a Windows 7 PC and Office 2007 Home Premium with Adobe CS6 and Premiere Elements installed.  I recently upgraded to an SSD and Elements didn't take well to it.  I wanted to uninstall it and then do a clean install onto the new SSD.  When I try do remove  it, though, I get a 1316 error message that "Adobe Premiere Elements.msi" is missing.  Interestingly, I searched for this on both of my drives and couln't find it, then went to my mirror back-up from before the SSD install and couldn't find it there either!
    It seems the best solution is to manually remove the folders and files, although I don't know what or where they are.  I did find a list of PSE 8 files and folders, but was concerned about going back three revisions.
    I would like a list of the files and folders used by Premiere Elements 11.  Also, are all of the "Media, People, Places, Events", etc. in Elements safely saved with the photos?  I definitely wouldn't want to loose all that information!

    http://helpx.adobe.com/photoshop-elements/kb/manually-remove-photoshop-elements-11.html.
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children
    If this post or another user's post resolves the original issue, please mark the posts as correct and/or helpful accordingly. This helps other users with similar trouble get answers to their questions quicker. Thanks.

  • Removing XML elements

    Hi all!
    I have a problem about an xml. I have to eliminate redundancy
    So from this xml:
    <xml1>
    <Property>
    <Parameters1>
    <Param>
    <name>A</name>
    <prop></prop> <!--this doesn't matter-->
    </Param>
    <Param>
    <name>B</name>
    <prop></prop> <!--this doesn't matter-->
    </Param>
    <Param>
    <name>C</name>
    <prop></prop> <!--this doesn't matter-->
    </Param>
    </Parameters1>
    <Parameters2>
    <Param>
    <name>A</name>
    <prop></prop> <!--this doesn't matter-->
    </Param>
    <Param>
    <name>C</name>
    <prop></prop> <!--this doesn't matter-->
    </Param>
    <Param>
    <name>D</name>
    <prop></prop> <!--this doesn't matter-->
    </Param>
    </Parameters2>
    </Property>
    </xml1>
    I want to obtain this xml:
    <xml2>
    <Property>
    <Parameters1>
    <Param>
    <name>A</name>
    <prop></prop> <!--this doesn't matter-->
    </Param>
    <Param>
    <name>B</name>
    <prop></prop> <!--this doesn't matter-->
    </Param>
    <Param>
    <name>C</name>
    <prop></prop> <!--this doesn't matter-->
    </Param>
    </Parameters1>
    <Parameters2>
    <!--Parameters A and C are missing-->
    <Param>
    <name>D</name>
    <prop></prop> <!--this doesn't matter-->
    </Param>
    </Parameters2>
    </Property>
    </xml2>
    There are just parameters without repeting.
    My code until now is:
    private String numeParam;
    private Vector elParam = new Vector();
    for (int i=0;i<rootlist2.getLength();i++)
    Element element2 = (Element)rootlist2.item(i); // rootlist is my doc xml
    if (element2.getLocalName()==Property)
    NodeList childrenName2 = element2.getChildNodes();
    for (j=0;j<childrenName2.getLength();j++)
    Element elemm = (Element)childrenName2.item(j);
    if ((elemm.getLocalName() == "Parameters1")||(elemm.getLocalName() == "Parameters2"))
    NodeList param = elemm.getChildNodes();
    for(int y=0;y<param.getLength();y++)
    bn=true;
    bas=true;
    Element childInProperty2 = (Element)param.item(m2); // acesta e de sters
    if (childInProperty2.getLocalName() == Param)
    NodeList tlist =childInProperty2.getChildNodes();
    for (int y = 0;y<tlist.length();y++)
    Element childInPUParam2 = (Element)tlist.item(y);
    if (childInPUParam2.getLocalName()== "name")
    numeParam = childInPUParam2.getTextContent();
    bas=false;
    if (bas==false)
    if (!elParam.contains(numeParam))
    elParam.addElement(numeParam);
    if (elParam.contains(numeParam))
    bn=false;
    break;
    } end if
    } // end for
    if (bn==false)
    ba = false;
    if (bn==false)
    System.out.println("C");
    ba = false;
    elParam.clear();
    this is working I a kind of way, but this remove some elements that is not god. I wonder... Is like elParam contains some strings but, after me is imposible.
    Thanks all

    Why don't you use XPath? Anyway.
    -> Get a List of the documents Node
    -> Get a List of all children
    You have to check each Node:
    -> if the node is not null
    -> if the node's name is not null
    -> if the node's content is not null
    -> if the node's name is equals (<name>)
    If the Node-Element is found, store it in a Collection (the reference of the node object).
    Later you could iterate the collection and remove all Nodes from the Document.
    Afterwards you can transfer the document to a xml file.
    btw: if you use XPath you have to be sure to use at least Java 1.5
    Regards,
    Florian

  • Removing DOM element effectively

    How can i efficiently remove child element from a Node? I have a scenario like this I have an xml doc given below
    <menudocument>
    <parentmenu name="menu">
    <item title="Home" url="http://localhost:8081/struts" permission="home.show"; />
    <menu name="create menus">
    <item title="Create Person" url="/struts/jsp/Personcreate.jsp"; permission="Hide" />
    <item title="Create Shop" url="/struts/jsp/ShopCreate.jsp"; permission="Hide" />
    <item title="Create Book" url="/struts/jsp/BookCreate.jsp"; permission="Hide" />
    </menu>
    <menu name="search">
    <item title="Search Book" url="/jsp/book!startSearch.action"; permission="book.search"; />
    <item title="Search Person" url="/jsp/person!startSearch.action"; permission="Hide" />
    </menu>
    <menu name="sample menu">
    <item title="Item Text1" url="itemurl.do"; permission="text1.item"; />
    <item title="Item Text1" url="itemurl.do"; permission="Hide" />
    </menu>
    <menu name="dummy menu">
    <item title="Dummy Title" rul="dummyurl" permission="title.dummy"; />
    </menu>
    </parentmenu>
    </menudocument> Here if the permission attribute of an element is 'Hide' I have to remove that element from the document
    I have a code snippet like below but i don't know why it is not removing all the elements with attribute value 'Hide'
    File menuFile = new File("XMLmenuFile.xml";);
    DocumentBuilder builder = Document().newDocumentBuilder();
    Document menuDocument = builder.parse(menuFile);
    NodeList nodes = menuDocument.getElementsByTagName("item");
    for (int i = 0; i < nodes.getLength(); i++) {
    Element itemTag = (Element) nodes.item(i);
    if (itemTag.getAttribute("permission")).equalsIgnoreCase("Hide")) {
    // remove the corresponding nodes from the new tree
    itemTag.getParentNode().removeChild(itemTag);
    } Any help will be greatly appreciated.
    Thanks,

    Is it only removing some of them? Then you are encountering the classic gotcha that when you remove an entry from a numbered list, you renumber all the entries after that one. But your code, which simply goes from 0 to n, doesn't account for that. If you traverse the entries from n to 0 then the problem doesn't arise.

  • Kill a thread and remove the element from the vector

    Hi All
    I have attached each Vector element to a thread which I later want to kill and remove that element from the Vector.
    Thread.join(milliseconds) allows this functionality to let the thread die after n milliseconds.
    However, I want to delete this element from the Vector now.
    Can someone please throw some light on this?
    Here the code I have written for this:
    try
         System.out.println(counter);
         int xCoord = generator.irand(25,200);     // X-coord of AP
         int yCoord = generator.irand(25,200);     // Y coord of AP
         listMN.addElement(new MobileNode((int)mnId,new Point2D.Double(xCoord,yCoord)));
         listMNcoords.addElement(new Point2D.Double(xCoord,yCoord));
         for(int i=0;i<vnuBS.returnBSList().size();i++)
              if(vnuBS.returnBSListCoords().get(i).contains(xCoord,yCoord)&&(vnuBS.returnBSList().get(i).getChannelCounter()<=3)&&(vnuBS.returnBSList().get(i).getChannelCounter()>0))
                   double c = exponential() * 10000;
                   long timeToService = (long)c;
                   System.out.println("BS "+vnuBS.returnBSList().get(i).id+" is connected to MN ");
                   vnuBS.returnBSList().get(i).reduceChannelCounter();
                   System.out.println("Channel Counter Value Now: "+vnuBS.returnBSList().get(i).getChannelCounter());
                   mobileNodesThread.addElement(new Thread(listMN.elementAt(mobileNodeCounter)));
                   mobileNodesThread.elementAt(mobileNodeCounter).setName(mobileNodeCounter+"");
                   mobileNodesThread.elementAt(mobileNodeCounter).start();
                   mobileNodesThread.elementAt(mobileNodeCounter).join(100);
    //                              System.out.println("Died");// thread dies after join(t) milliseconds.
                   System.out.println("ListMN getting generated : " + mobileNodesThread.get(mobileNodeCounter));
              else if(vnuBS.returnBSListCoords().get(i).contains(xCoord,yCoord)&&(vnuBS.returnBSList().get(i).getChannelCounter()<=0))
                   listMN.remove(this.listMN.lastElement());                         //dropcall
                   System.out.println("Removed "+mnId);
                   removeCounter++;
                   mnId = mnId--;
                   mobileNodeCounter--;
              mnId = mnId+1;
         Thanks a lot.

    I'm not sure if what you are trying to accomplish is correctly implemented.
    The method join does not kill the thread. It will wait for the specified time for the thread to exit. If you want the thread to run for a specified ammount of time, develop the run method of that thread with that in mind. Do not try to kill it from the outside, but let it terminate itself (gracefull termination).
    Now for your question regarding the vector (you should probably be using ArrayList nowadays): I would implement the observer pattern for this job. Make the threads post an event on the interface when they are done, let the main thread register itself with the threads and synchronize the method that handles the events. In that method you can remove the object from your list.
    I'm not sure if you want to use thread anyhow, could you tell us what it is that you are trying to accomplish?

  • WebDynpro Java: how to remove blank element from Table and Dropdown.

    Hi  Folks
    In a webdynpro application,
    I created a table and witten the below code to populate the table
         IPrivateDummyView.IFirst_TableElement First_Table_Element = null;
         First_Table_Element = wdContext.nodeFirst_Table().createFirst_TableElement();
         First_Table_Element.setF_Value("One");
         wdContext.nodeFirst_Table().addElement(First_Table_Element);
         First_Table_Element = wdContext.nodeFirst_Table().createFirst_TableElement();
         First_Table_Element.setF_Value("2");
         wdContext.nodeFirst_Table().addElement(First_Table_Element);
    As per the code, i got 2 row in the table.
    But , i have one Empty row on top of the table ,  how to get ride of this.
    i find the same problem happening with dropdown too, where i used DDBI, i populated a the content as mention, but i initial 2 row as blank and then i have my own elements ,as per my code.

    >
    > how to remove blank element from Table and Dropdown
    >
    Change selection property of related node to from 0..1 to 1..1 (mandatory)
    Re: DropdownByIndex and empty line (Thread: DropdownByIndex and empty line )
    Re: Can the empty selection be removed from element dropdownbykey(Thread: Can the empty selection be removed from element dropdownbykey )
    Edited by: Anagha Jawalekar on Nov 18, 2008 10:28 PM

  • Removing vector elements

    hi there
    i have a vector, that has the contents of a directory as elements. in the post proccessing phase i trie to remove all elements that are .java files or are class files that end with Options.class or Options$1.class.
    i use this code
    for(int i=0; i < plugins.size(); i++) {
       theFilename = plugins.elementAt(i).toString();
       System.out.println("TheFilename: "+theFilename);
       if(theFilename.endsWith(".java") ||
          theFilename.endsWith("Options.class") ||
          theFilename.endsWith("Options$1.class")) {
            System.out.println("Removed: "+theFilename);
               plugins.remove(theFilename);
    }the problem is, that that code always leaves one element in the vector, that should be sorted out by this loop. anyone an idea ?
    - rebel

    Hi jaylogan again,
    i read your second answer. I use the methods of the file-class. So it seems better to paste the whole method in here. note, the for loop, that removes filenames is twice there. after first test i found ou, that the second loop is removing the last filename that should not be in the list. that worked as long i had only one plugin in the plugin directory. when i added a second plugin the double for-loop was not working anymore. there is still an element left that should not be in the list.
    sourcecode:
    public void createPluginList() {
              String theFilename;
              String plugInDir = getCurrDir()+File.separator+"plugins";
              File dir = new File(plugInDir);
              FilenameFilter filter = new FilenameFilter() {
                   public boolean accept(File dir, String theName) {
                        return theName.startsWith("Pi");
             String[] contents = dir.list(filter);
             if (contents == null) {
                   // Either dir does not exist or is not a directory
              } else {
                   for (int i=0; i < contents.length; i++) {
                        plugins.addElement(contents);
              System.out.println("------------");
              for(int i=0; i<plugins.size(); i++) {
                   System.out.println(plugins.elementAt(i).toString());
              System.out.println("------------");
              for(int i=0; i < plugins.size(); i++) {
                   theFilename = plugins.elementAt(i).toString();
                   System.out.println("TheFilename: "+theFilename);
                   if(theFilename.endsWith(".java") ||
                   theFilename.endsWith("ptions.class") ||
                   theFilename.endsWith("ptions$1.class")) {
                        System.out.println("Removed: "+theFilename);
                             plugins.remove(theFilename);
              System.out.println("------------");
              for(int i=0; i < plugins.size(); i++) {          // I dont know why i have to run this
                   theFilename = plugins.elementAt(i).toString(); // a second time, but only then
                   System.out.println("TheFilename: "+theFilename); // it works
                   if(theFilename.endsWith(".java") ||
                   theFilename.endsWith("Options.class") ||
                   theFilename.endsWith("Options$1.class")) {
                             System.out.println("Removed: "+theFilename);
                             plugins.remove(theFilename);
              System.out.println("------------");
              for(int i=0; i<plugins.size(); i++) {
                   System.out.println(plugins.elementAt(i).toString());
    -rebel

  • Can We Use Multiple Edgehero Classes On The Same Element?

    Does anyone know if it is possible to add multiple Edgehero classes to the same element? More specifically, I would like to use RotateX and RotateY on a rectangle, but it only seems to do one or the other, adding both classes to the element doesn't make it rotate in both directions.

    Maybe check out the Star Wars demo to see if that would help.
    Rob got the idea from the one I made earlier and here is the code:
    sym.$('gradient').css('background', '-moz-linear-gradient(top, rgba(0,0,0,1) 0%, transparent 100%)');
    sym.$('container').css('-moz-transform-origin', '50% 100%');
    sym.$('container').css('-moz-transform', 'perspective(250px) rotateX(25deg)');
    // Chrome and others
    sym.$('gradient').css('background', '-webkit-linear-gradient(top, rgba(0,0,0,1) 0%, transparent 100%)');
    sym.$('container').css('-webkit-transform-origin', '50% 100%');
    sym.$('container').css('-webkit-transform', 'perspective(250px) rotateX(25deg)');
    // Internet Explorer
    sym.$('gradient').css('background', '-ms-linear-gradient(top, rgba(0,0,0,1) 0%, transparent 100%)');
    sym.$('container').css('-ms-transform-origin', '50% 100%');
    sym.$('container').css('-ms-transform', 'perspective(250px) rotateX(25deg)');
    and the orginal file before edgeHero;
    https://app.box.com/s/068vx5x6lj5t2yydrx17

  • How to use the same element in different photoshop files?

    It occurs to me often that I use the same element in different photoshop files, a header or footer shown in the example below. So when the footer changes in one document, I need to change this footer in every other single document.
    Is there a possibility to use some kind of template, one single document,  that can be placed in different files , which is still editable afterwards?
    Thanks in advance.
    I'm using Photoshop CS6

    In a single document you can have several pages and these pages may have headers and footers that share smart objects.  If you replace the contents of the an embedded smart object on one page page that is shared on an other page the pages you will see both pages contents are changed. For they share the common object.   It is also possibly to have independent smart object layers. It depends how you create the layers in the single document.
    Example one sharing a smart object hi-light a smart object layer and use menu layer>Duplicate Layer... This will create a second smart object layer that share a common smart object. Each layer has is own associated transform. Do it again and you will have three layers the share a common smart object. So you can use each layer associated transform to position and size the layers contents. Make a picture package for example. When you hi-light any of the three smart layers and you use menu Layer>Smart Objects>Replace Contents... all three layers contents will be replace with the new smart object.  Care must be taken to replace the smart object with an identical size object for only the object is replaced the three associated transform for the three layers are not replaced or changed.
    Example two independent smart objects  hi-light a smart object layer and use menu layer>Smart Objects>New Smart Object via Copy.  This will  create a second smart object layer that has it own embedded smart object copy.  Do it again and you will have three all have independent embedded smart object that are identical.  However they do not have to remain identical.  For example if the first smart object layer was created by using ACR to open a RAW file as a smart object layer the embedded object is a copy of the raw file and its associated RAW conversion settings.  Double clicking on one of the smart object layers and you will see ACR open on its embedded RAW file with the embedded RAW conversion setting.  Changing these settings will update the layer smart object content with new ACR setting and pixel when you click OK in ACR. Repeat for the third and you will find you have three different raw conversions in Photoshop you can mask and blend together to bring out detail.
    I think what your missing is that a smart object contains a copy of the original object.  Changing the original after creating a smart object layer in document will not effect the smart object layer at all. Its independant from the original having a copy of the original. Only changes to the smart object layer and its embedded smart object effect smart object layers.

  • Help needed in removing duplicate items of list box  in java

    How to remove duplicate items of list box while dynamically inserting (on-click event)
    It is not identifying duplicate data
    Variable name is HP_G1
    HP_dmg1 = (DefaultListModel) HP_G1.getModel();
    int a = HP_G1.getModel().getSize();
    System.out.println("HP list no--------> "+a);
    if(a!=0)
    for (int j=0; j<a; j++)
    String item1 = String.valueOf(HP_List.getModel().getElementAt(j));
    System.out.println("HP list added--------> "+item1);
    if(HP_dmg1.equals(item1)){
    HP_dmg1.remove(j);
    else
    HP_dmg1.addElement(GPL);
    }

    Your code is unreadable, so I'll ignore it. In the future please press the message editor's CODE button to format code.
    As to your problem, to the point you normally use a Set instead of List when you don't want duplicates in a collection.

Maybe you are looking for

  • How to get Report Builder to print a section on the same page

    I have a section of my report that is three bands. A header band, the detail band, and a total line band. Sometimes this section will get split up and print part on the next page. So basically I need for this section to print on the same page. I know

  • Cannot connect to wireless network

    Hello, I am trying to connect to my wifi network which is secured using WPA2. I have tried wpa_supplicant and netctl. Relevant part of ip link 3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000 link/ether 00:0

  • Changes to an order through Call Transaction not showing up in change log

    I m having a problem such that if I update an order programmatically with Call Transaction u2018VA02u2019, the order does get updated updated but I donu2019t see the changes in the change log. I m only updating the order quantities. However if I upda

  • Locked folder unable to unlock

    hello, so i burned a dvd with .mov and .dv files from imovie, and the burn folder stays in my desktop locked. when trying to unlock it gives me a error message... the option is not active and although i have the permissions when trying to change them

  • Quality loss when converting pro res to mp4

    Hi I have a problem with the workflow from After Effects to a final .mp4 video. I have been editing time lapses in After Effects, and exporting them as Pro Res HQ- all good so far. However, I can´t seems to be able to convert the Pro Res file to a .m