How to removie a duplicate element of array

i have this code so far can someone please help
public static int [] remove(int[] a, int[] b){
for(int i = 0; i < a.length; i++) {
if(a[i] == b) {
int[] newInt = new int[a.length - 1];
return newInt; // We need something here
return a;

First, please use [ code] and [ code] tags to denote code; it makes it much more readable.
Second, your arguments for the function don't make sense with relation to your subject. So, running on the asumption that I know what you mean through the subject, here goes:
You probably want the arguments to be:
(int[] a, int b)Whereby you want to remove the element that equals b . So, what you would want to do in such a situation is:
for(i = 0 to a.length) {
if(a[i] == b) {
  //You have reached the element to throw away.  Set a flag saying you have reached this point
// If the flag is set, add a[i+1] to the new array; otherwise add a[i] to the new array.
return a;

Similar Messages

  • How can i retrieve missing element in array

    how can i retrieve missing element in arrays if array length is exceeded

    Not sure about what the question means, but could it be that OP is not aware that the first element in an array is at index 0 (not 1) ?
    <a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html" style="background:url(http://java.sun.com/docs/books/tutorial/figures/java/objects-tenElementArray.gif) no-repeat; width:400; height:145;"></a>

  • Hows to remove clones/duplicates on iPhoto?

    how to remove clones/duplicates on iPhoto?
    Thanks
    JohnFMe

    Hi Larry,
    I have not been importing photos for some time.  Literally, I open I Photo and pictures from my library are dupe'd, side by side - 2 - 3 even four side by side.  I deleted hundreds of faces pulled from photos that just appeared in the library.  Nope.  I don't use the FACES feature.  These simply appeared in my library.  Other photos that are not mine - look like they must be from web sites or something have appeared as well. 
    When I was importing from my camera I always checked the box to not import any duplicates.  It appeared that was being done properly.
    I shoot raw +jpeg now with a new camera and so two of each shot comes into the library but the dupes I'm talking about are pretty much happening throughout years of pictures.
    Yesterday I met w/a tech at Apple and upgraded to the most current I Photo.  But, the comments I've seen seem to be happening on the later versions as well.

  • How to remove a duplicate photo from an album.  Photo sweeper says there are no duplicates in photos

    how can I remove duplicate photos from albums,  I have removed 2000 duplicates from iphoto using photo sweeper.  still duplicates in my album.

    thanks, but in my albums trash is greyed out and hitting delete does nothing..
    Is your album a smart album? You can only remove photos from smart albums by changing the smart rules for the album.
    If I move the duplicate to another new album, can I then trash the new album?
    It is still not clear, what duplicates you are asking about. Photos in albums are not duplicates. Albums are showing you the same photos you are seeing in your events, just grouped differently for easy access. You can delete any album completely and will still have the same photos in your iPhoto library.
    If Photo sweeper says,"there are no duplicates", you probably really do not have duplicates in your iPhoto library.
    You only have duplicates, if you are seeing identical photos twice in events, but not, if you you are seeing the same photo once in an album and once in an event. You can check that, by ctrl-clicking any photo in an album and selecting "Show Event". Then you will see, what the event is, that is containing this particular photo.

  • How to remove the duplicate Columns in Multiple Rows?

    Hi,
    I want to remove the duplicate columns in a Multiple Rows.
    For example:
    Now i'm getting the output like this
    S_NO Order_number Assy_item Assy_Desp Item_Number
    1     S3123 12345 TEST     *1245*
    2     S3123 12345 TEST     *1256*
    3     S3123 12345 TEST     *1289*
    4     S3123 12345 TEST     *1223*
    5     S4123 42345 SAMPLE *4568*
    6     S4123 42345 SAMPLE *5656*
    7     S4123 42345 SAMPLE *4558*
    the Original output should be like this
    S_NO Order_number Assy_item Assy_Desp Item_Number
    1     S3123 12345 TEST     *1245*
    2                         *1256*
    3                         *1289*
    4                         *1223*
    5     S4123 42345 SAMPLE *4568*
    6                         *5656*
    7                         *4558*
    note: Alignment Problem all the Bold Numbers are Item Number(Last Column)*
    i'm using XML and RTF template.
    RTF Template is a Basic Table like Structure
    i pasted the XML code below
    <?xml version="1.0" encoding="UTF-8"?>
    <dataTemplate name="items" version="1.0">
    <parameters>
    <parameter name="P_DATE" dataType="date"/>
    <parameter name="P_DEPT_NO" dataType="varchar2"/>
    </parameters>
    <dataQuery>
    <sqlStatement name="ROW1">
    <![CDATA[
    SELECT
    SUBSTR(IMGR.ORDER_NUMBER,3,2) MACHINE_NO
    ,IMGR.ORDER_NUMBER
    ,IMGR.ASSY_ITEM_NUMBER
    ,IMGR.ASSEMBLY_DESCRIPTION
    ,IMGR.ITEM_NUMBER
    ,IMGR.ITEM_DESCRIPTION
    ,SUBSTR(IMGR.ORDER_NUMBER,1,2) DEPT_NO
    ,IMGR.PLAN_DESCRIPTION
    FROM XXI.IGL_MRP_GROSS_REQUIREMENTS IMGR
    WHERE IMGR.DEMAND_TYPE IN ('Discrete job','Non-standard job')
    AND IMGR.PLAN_DESCRIPTION ='MRP-PRODUCTION'
    AND IMGR.DEMAND_DATE <= :P_DATE
    AND SUBSTR(IMGR.ORDER_NUMBER,1,2) IN (&P_DEPT_NO)
    ORDER BY
    DEPT_NO
         ,MACHINE_NO
    ,IMGR.ASSEMBLY_DESCRIPTION
    ,IMGR.ASSY_ITEM_NUMBER
    ,IMGR.ORDER_NUMBER
    ,IMGR.ITEM_NUMBER
    ]]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="G_IGLOO_QA_FPI" source="ROW1">
    <element name="MACHINE_NO" value="MACHINE_NO"/>
    <element name="ORDER_NUMBER" value="ORDER_NUMBER"/>
    <element name="ASSY_ITEM_NUMBER" value="ASSY_ITEM_NUMBER"/>
    <element name="ASSEMBLY_DESCRIPTION" value="ASSEMBLY_DESCRIPTION"/>
    <element name="ITEM_NUMBER" value="ITEM_NUMBER"/>
    <element name="ITEM_DESCRIPTION" value="ITEM_DESCRIPTION"/>
    <element name="DEPT_NO" value="DEPT_NO"/>
    <element name="PLAN_DESCRIPTION" value="PLAN_DESCRIPTION"/>
    </group>
    </dataStructure>
    </dataTemplate>
    Please Share your ideas.
    Thank
    Aswath

    hi Ananth,
    i tried the logic but its also not printing the First Line.
    Syntax:
    <?if:ORDER_NUMBER!= ORDER_NUMBER?><?ORDER_NUMBER?><?end if?>
    I think this condition works fine if it is start from second line of the row.
    Output:
    S_NO Order_number Assy_item Assy_Desp Item_Number
    1     12345 TEST     1245
    2     12345 TEST     1256
    No Order_number displayed.
    i hope you got my point. Please help me to get through it.
    Thanks
    Aswath

  • How to remove/ignore the element using SAXParser

    hello all,
    I want to parse the text content in string from the existed xml file. but had problem with the parser. Does anyone have good idea, how to remove or ignore the <link> tag in tag <text>?
    IS: the output is only the rest of part text behind <link style="blue" src="www.test.com" />.
    Wanted: the whole text in <text> tags. like "Reach more customers by creating targeted micro-sites using test's multi-store retailing functionality."
    Given below is my code :
    <?xml version="1.0"?>
    <test xmlns="http://www.test.com/test">
    <title>test title</title>
    <text>Reach more customers by creating targeted micro-sites using test's<link style="blue" src="www.test.com" /> multi-store retailing functionality.</text>
    </test>java code using SAXParser
      public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
      public void endElement(String uri, String localName, String qName) throws SAXException {
        if (qName.equals("text")) {
          System.out.println("content: " + text);
      public void characters(char[] ch, int start, int length) throws SAXException {
        String str = new String(ch, start, length);
        if (str.length() > 0)
          text = text == null ? str : text + str;
    ...Edited by: lauehuang on Sep 9, 2008 4:37 AM

    i think u can't modify the xml file using SAX
    SAX is only for reading XML
    for any modifications in xml file u have to use DOM parser....
    correct me if i m wrong....
    Thanks & Regs
    Ravi

  • How to remove the duplicate HR record from per_all_people_f table

    Because of some mistake user has created two records for one employee one with start date 4th may 2010 and end date with 1st may 2011 and another with start date with 2nd may 2011 and end date is 31st of dec 2012.
    When I go to enter and maintain employee i found the record which starts with 4th may 2010 and end date with 1st may 2011.
    Please let me know how to remove the end date from this record.
    when I ran the query
    select * from PER_ALL_PEOPLE_F PAPF where upper(first_name)='UDAYA';
    i have first four column for this type.I want to remove the first row from here
    41246     02-MAY-11     31-DEC-12     81     1125
    41246     04-MAY-10     01-MAY-11     81     1125
    Please help.
    Regards,
    Prakash

    Okay, so you wish to just have one person record from the 4th May 2010 through to the 31st December 4712, right?
    In that case, do this:
    1) Query the person in the Enter & Maintain person form
    2) Hit Delete on the toolbar
    3) Select "Delete Next Change" from the date-track mode and save
    4) Re-query
    Now the date-track update from 2nd May is gone.

  • How to remove all duplicate values from a column

    For some reason when a user is adding a record, it duplicates it three times. Why is that happening?
    Since there is many how can I remove any records that contains a duplicate in a specific column?

    Is this happening for all lists in site collection or this is the only one?
    Check on the list if there is any workflow attached. If yes then open the workflow in designer and check its logic it might be written to copy list items.
    Investigate if there is an event receiver deployed in your site where it creates duplicate entries. There has to be some custom code running which is causing this duplication otherwise out of the box behavior of lists is never like this.
    Please remember to click 'Mark as Answer'
    if the reply answers your query or 'Upvote' if it helps you.

  • How to change a specific element in array

    hi 
    i have an 1d intialized array
    i want to take the existed array and for example add +1 for the 5th element
    how can it be done?
    thanks
    Solved!
    Go to Solution.

    In a typical application you would want to repeat that operation to form a simple histogram. This is most easily achieved by keeping the array in a shift register and repeating the operation in a FOR loop until all data is processed.
    My very simple example from a few years ago can be found here. In this case we are counting the number of occurences of small integers in a 1D array. Modify as needed.
    LabVIEW Champion . Do more with less code and in less time .

  • How to remove a duplicate driver?

    i have a Leybold 23xxxx pressure meter. By accident there are two Leybold 23xxxx drivers in the system now and i get strange errors with my VIs.
    I have installed one driver via LV (this is a very old version)
    and there is another (newer)  Version i dont know where it came from and why NI did not install the latest version.
    How can i remove the unused drivers?
    There is a old unused 2009 LV version still installed, but i could not find a uninstaller. Will i have to remove it with some tricks, or can it stay?
    ================================
    system: Win7 and debian stable
    Solved!
    Go to Solution.

    Instrument drivers are in the "LabVIEW\instr.lib" folder. Each driver should be in its own folder. To delete it, just delete the folder. You may need to update the palette menu to reflect the removal of the directory.
    Also, what do you mean by NI installing the driver? Are you referring to using the Help -> Find Instrument Driver? If so, what did you enter in the search criteria? Leybold isn't even in the list of manufacturers.

  • How to remove the duplicate record in DART Extract

    Hi Guys,
    We are getting duplicate record when we do validate the DART extract file through DATA VIEWS for FI General Ledger Account Balances. If any one have experance on this, pls help us.
    Following are the steps we done to Validate the DART EXTRACT File for FI General Ledger Account Balances.
    1. We have run the DART extract program to extract the data from table to directory file by period vice in T.code FTW1A.
    2. When we do validate the data from DART extract file through DATA VIWE for FI General Ledger Account Balances in T.code FTWH, getting duplicate record.
    We unable to find out from where the duplicate records are coming out. will be great if any one can help us immediately.
    Thanks & Records,
    Boobalan,v

    If the dup records are actually in the DART View versus the DART Extract, you could try OSS Note 1139619 DART: Eliminate duplicate records from DART view.
    Additional Note - 1332571 FTWH/FTWY - Performance for "Eliminate duplicate records
    Colleen
    Edited by: Colleen Geraghty on May 28, 2009 6:07 PM

  • How to remove duplicates

    Hi
    i am removing duplicate records while importing bulk data into the table...I am checking for some columns...when they are same, i am removing the old records...i have used the following code to remove duplicates...
    execute immediate 'DELETE FROM test1 WHERE ROWID IN (SELECT ROWID FROM (SELECT ROWID,ROW_NUMBER() OVER (PARTITION BY c1,c2 ORDER BY 1) row_no FROM test1)WHERE row_no > 1)';
    here i check c1 and c2 columns...if they are same the old records are to be deleted...but in this code, the new records are deleted..can anyone say how to remove old duplicate records?
    Vally

    Hi
    i am removing duplicate records while importing
    bulk data into the tableWhat you mean by using "while"?
    During the process of importing(read inserting) - you want to delete duplicate records?
    As you say in the following you have C1 and C2 - using both of them - you find duplicates.
    I deem you have other columns besides C1 and C2. And these columns have different fileds in NEW record and OLD record - then why don't you use UPDATE statement?
    ...I am checking for some
    columns...when they are same, i am removing the old
    records...i have used the following code to remove
    duplicates...you should clarify on what criteria you separate old records from new records and place this condition in your query.
    E.g. you have a field DATE_OF_ENTRY
    and the latest one is the new record which shouldn't be deleted
    then you would be able to put it into your delete statement:
    DELETE FROM test1
    WHERE ROWID IN (SELECT ROWID
                       FROM (SELECT ROWID,
                                    ROW_NUMBER() OVER(PARTITION BY c1, c2 ORDER BY DATE_OF_ENTRY desc) row_no
                               FROM test1)
                      WHERE row_no > 1)

  • 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.

  • How to remove duplicate emails from mac mail

    i have moved my email message from outlook for mac 2011 and downloaded all the mails form 3 accounts of google app for business.
    now my mail box shows 60000 emails and is occupying more then 40GB. 50% of the mails in my mail box must be duplicate. I want to know how to remove the duplicate emails from my account.

    Apologies, this was posted here in error. Please find updated post here: https://discussions.apple.com/message/27261965#27261965

  • Removing a duplicate Feed in iTunes Music Store

    Does anyone know how to remove a duplicate listing in the iTunes Music Store?
    I have two copies of my podcast and people are subscribing to both. I think they both go to the same feed. I've tried clicking on "report a podcast" to remove...about 8 times! no luck. Any advice?
    here is the feed address: http://www.thespotlab.com/SpotLab.xml
    thanks for any help!
    dina mande

    Sell the gift card to someone who IS willing to upgrade?

Maybe you are looking for

  • Printing from a PhotoSmart 3300 All-in-one printer

    When I try to print something, the first page printed contains information on filename, directory, template, Creation date, etc. How do I stop this from printing?

  • 3D Motion Tracking Error/Crash in progress [Urgent Help Please!]

    Hey there! I'm an video editor and I use 3D Motion Tracking a lot but recently every time I use it, it comes up with an error and says crash in progress, It never used to do it and I can't seem to find any solutions to fix it. Computer Specs: Manufac

  • Phone screen not lighting up?

    I have an LG Extravert, prepaid. For the past month or two, I have had a lot of difficulty with the screen. It often does not light up. It lights up, but nothing displays, and it often shows up in negative, or backwards, or fades away. I have been tr

  • Settings for icloud in outlook for mac

    Up until today my outlook for mac worked just fine with my .me email.  Now it cannot find the server.  I also today got a new license agreement for icloud on my phone and noticed on my phone it is using the icloud smtp server.  Are there new settings

  • Unexpected File Format in Flash Pro 8

    Hi, I have downloaded the trial version of Flash Professional 8 for a homework assignment and when I try to open the file that the professor gave us I get  an error that states "Unexpected File Format"  I have tried almost everything to fix the file