List collections

Hi,
I have 2 lists in java like these 2.
First has some distinct values as
#home
#wall
#Bed
The second list has values as
#home
vlu
3 rooms
etc
#wall
som value
value
#home
some value
and so on
I want that when I iterate to first list to find all corresponding values
the output should be something similar with
#home
vlu
3 rooms
etc
some value.
Can you help me with this problem?
Thank you,
Cosmin

Just iterate them both at the same time.

Similar Messages

  • How to write from a linked list collection to a text file.

    Hi,
    I want to write my data in linked list collection to a text file.
    the following is the code of my linked list. how do i write it
    Iwant the data to be comma separated while writing it to a text file.
    please help.
    class MailList
            public static void main(String args[])
                    LinkedList m1 = new LinkedList();
                    m1.add(new Address("J.W.West", "11 Oak Ave",
                           "Urbana", "IL", "118011"));
                    m1.add(new Address("H.S.sandy", "1 k ve",
                           "Bana", "L", "18011"));
                    m1.add(new Address("K.Satish", "1 104 Clarence Street",
                            "Strathfield", "NSW", "135"));
                    Collections.sort(m1);
                    Iterator itr = m1.iterator();
                    while(itr.hasNext())
                            Object element = itr.next();
                            System.out.println(element + "\n");
    }

    look at the API for FileWriter.
    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • Demantra Price List Collections

    We are collecting price lists from EBS into Demantra and found that not all items from the EBS Price List are included in the collection and download into Demantra msd_dem_price_list table. For example, for one price list, the EBS Price List contains 4014 distinct items with active prices; however ,after price list collection is run into Demantra, only 3160 distinct items with prices are populated in the msd_dem_price_list table for this series.
    Are there any system constraints that limit the items/pricing records included in the price list collection?
    Thanks
    Edited by: user566845 on Oct 18, 2010 3:10 PM

    Hi Raj,
    Thanks a lot for the reply.
    Actually I was thinking of loading the price at a daily level and at a Item - Location level so I'll have the SALES_DATE, ITEM_CODE, LOCATION_CODE, PRICE colums.
    Let's say that I have the next situation: if one product has price 5 starting with 01.01.2011 till 05.31.2011 and starting with that date the price will be 6. How do I define that in the flat file ?
    1. I insert 2 lines i.e.
    SALES_DATE ITEM_CODE LOCATION_CODE PRICE
    01.01.2011 X Y 5
    05.31.2011 X Y 6
    OR
    2. I insert 1 line for each date starting with 01.01.2011 till 05.31.2011 and so on i.e.
    SALES_DATE ITEM_CODE LOCATION_CODE PRICE
    01.02.2011 X Y 5
    01.03.2011 X Y 5
    01.04.2011 X Y 5
    05.31.2011 X Y 6
    06.01.2011 X Y 6
    06.02.2011 X Y 6
    06.03.2011 X Y 6
    Thak you
    AMC

  • Working with List, Collection or Map

    Hello everyone,
    I have the following situation: I must add some values to a List, Collection or Map, and then retrieve them do put them in a combo box. My doubt is: which of them I should use?
    I wanna add a string working as an index and another working as a description. Like this:
    - "First string", "Hey here's my first string"
    - "String 2", "number 2 now"
    So, when I add it to the combo (which is actually a html:select), I wanna show the description and get the value.
    Which of them should I use?

    public Map getAtributosColecao(){
    Map mapa = null;
    mapa.put("colecao","Cole��o");
    mapa.put("descricao","Descri��o");
    return mapa;
    }is it correct? 'cause when I call it from another
    class, I get a nullPointerException...Of course you get that exception.
    Map mapa = null;Ok, mapa is null here.
    mapa.put("colecao","Cole��o");Duh?

  • MRP list: collective requirements (MD06) in the background mode

    Hi Friends,
    We have requirement to run MRP list: collective requirements (MD06) in the background mode per MRP controller. Is there any way we can run MD06 in the background?
    Appreciate your response.
    Thanks,
    Srinivas

    Dear Srinivas
    if you need to run planning as a background job please try t-code MDBT;
    as far as i know you can't run MD06 as a backgroun job.
    you could ask your abaper to create a custom program based on functional module MD_MRP_LIST_OVERVIEW
    after that you will set up this custom code as a background job.
    good luck!

  • Lists/collections in JDBC

    Hi all,
    Does anyone know if it is possible to pass to an Oracle stored procedure a Java defined list/collection/array/vector as an IN parameter?
    E.g. an array/list of Strings or a vector of booleans.
    I know it is possible to pass an sql.array, but I think it is not possible to define one in the Java code itself.
    Thanks in advance,
    Daniel Palomo van Es.

    CC JDBC Parameters:
    Connection:
    Format need to be specified as  -   jdbc:oracle:thin:@hostname:port:SID
    jdbc: oracle:thin:@(DESCRIPTION =     (ADDRESS_LIST =       (ADDRESS = (PROTOCOL = TCP)(HOST = ntbomsap13)(PORT = 1527))     )     (CONNECT_DATA =       (SID = XI3)       (SERVER = DEDICATED)     )   )
    Here in this connection url I have replaced: @hostname: port: SID with the TNSNAMES file content.
    Processing Parameters:
    1.Query SQL Statement: e.g.- select empid, empname, empage from emp_det where empid>1
    2. Update SQL Statement: e.g - update emp_det set flag=2 where flag=1
    Regards,
    Anurag

  • Add_item : Attributes list collection sort order

    Hello:
    I created multiple custom attributes and added them to my custom item type. I need to apply these attributes while adding an item programmatically.
    1) How do i define the order of the Attributes list via the Portal builder so as to match the corresponding values read from a list/table,etc. ?
    2) The ordering arrow buttons in the attribute list of my custom item type does not match the result set from my query. I tried all options of "order by" clause. Here is the query - (componenttype is the name of my custom item type)
    select iatts.ID
    ,atts.caid
         ,atts.DATA_TYPE     
         ,atts.CAID
         ,atts.NAME,atts.DISPLAY_NAME
         ,iatts.ITEM_TYPE_ID
    from wwsbr_item_types itypes
    ,wwsbr_item_type_attributes iatts
    ,wwsbr_attributes atts
    where --itypes.caid = 133
    itypes.name like 'ComponentType'
    and itypes.ID = iatts.ITEM_TYPE_ID
    and iatts.ATTRIBUTE_ID = atts.ID
    --and atts.CAID = 133
    order by atts.id
    3) I need to expect a certain order of the attribute ids, when bulk collecting into the attributes array, in order to populate the values collection in the same. So, how do I determine the order of the attributes ids ?
    4) Is there a better way to do this ?
    Thank You.
    regards
    Ananth

    Document Sets are great tools for grouping multiple documents together. However, if every set has exactly one document, it would be better to just upload the file and not place it within a Document Set:
    Uploading documents using object model - http://msdn.microsoft.com/en-us/library/office/ms454491(v=office.14).aspx
    Uploading documents using web services -
    http://cecildt.blogspot.com/2010/10/upload-documents-to-sharepoint-2010.html
    If you have requirements to use Document Sets, keep in mind that this adds a layer of complexity beyond a simple Document Library. Behind the scenes, each Document Set is treated as a separate folder, and although can you query items within it, there might
    be extra steps for getting the sort order to ignore the folder structure. Can you try setting the Scope to be "Recursive" and also specify that you are looking only for files and not folders:
    <Eq><FieldRef Name='FSObjType'/><Value Type='Lookup'>1</Value></Eq></Where>
    Dimitri Ayrapetov (MCSE: SharePoint)

  • Query/Report to list collections in a Folder

    does anyone have a query / report that lists the collections contained in a folder? I've found powershell scripts for this but they're not translating over with the same logic as a query.
    Thanks.
    Jason

    does anyone have a query / report that lists the collections contained in a folder? I've found powershell scripts for this but they're not translating over with the same logic as a query.
    The logic should be fairly close. What does the PowerShell script look like?
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

  • Passing list collection from page to page

    Using wp 8.1 and c#, I need to build a collection on one page1, then use the collection throughout the app for every page including page2, page3, page4, etc.
    Can anybody offer advise to consider?
    I thank the Lord Jesus for your kind effort and patience with me (Jeremiah 9:23-24 of the Holy Bible).

    Is this Silverlight or is it windows store app?
    It doesn't matter a great deal.
    You have three options.
    1)
    You can add any old object you like to resources and there's an application scoped set of resource.
    In windows store apps I think that'd be app.current.resources and in silverlight it's application.current.resources.
    You do:
    Application.Current.Resources.Add("somekey", yourlist);
    and that adds it to your resources.
    App.current... for win store app.
    To get a reference back to that thing ( note, it's a reference and therefore the same object).
    List<t> mylist =Application.Current.Resources["somekey"] as List<t>;
    Obviously, that list can instead be some other sort of collection and <t> is the type of the objects in it.
    You can see this approach used in one of my WPF samples:
    https://gallery.technet.microsoft.com/Dynamic-XAML-Composed-View-e087f3c1
    This shares two observable collections in a similar manner.
    It proves they are definitely the same object because you can edit a person and see the changes immediately in the corresponding datagrid row.
    2)
    You could alternatively send the List<t> using Mvvm Light messenger in an object and subscribe to that object type in the "receiving" pages.  They would have to be in memory and I think option 1 is your best bet.
    3)
    You could create the collection in one place - like mainpage eg.  Then pass that collection via the constructors of the other pages as you new them up.  I don't really like this approach because it introduces a dependency to all those pages which
    means testing etc is harder.   I don't consider it a professional approach if there's an alternative - but it's an approach plenty of professionals advocate so your mileage may vary.
    It's not really any simpler than using resources.
    Hope that helps.
    Recent Technet articles:
    Property List Editing ;  
    Dynamic XAML

  • Source list Collective processing

    Hi All,
         I have a scenario where i need to do Collective generation of Source list for few vendors using tcode ME05..
        As i have not used this functionality earlier, can you tell me in detail how to execute this in system ...
          Thanks
        Regards..
        Akkshaya

    Hi
    you generate the source list for several materials by using ME05.
    1.Enter the materials for which source list to be generated
    2.Enter the plant
    3.Select all records for Material and Plant (System should consider only outline agreement items, only info records, or both be taken into account)
    4. Enter validity periods
    5. Select  Exixting records option based on requirement
    Execute 
    A list of the source records to be generated is displayed. Already-existing source list records whose validity periods are thus changed are also listed.
    Select the source list records you want to include in the source list.
    <b>Fixed or blocked Source list records:</b> You can mark a source list record as "fixed" or block it. A "fixed" source represents the preferred source of supply, whereas a "blocked" source is one from which you are not allowed to order.
    Select the desired source list record. Then choose Edit -> Fix, or Edit -> Block.
    Choose  save to store the selected source list records for the displayed material in the source list.
    Exception messages are displayed by the system. Press ENTER to continue the saving process.
    Regards
    Ramakrishna

  • Properties, Casting, and Collections.list

    How do I make the following code work properly, without warnings?
    import java.util.Properties;
    import java.util.Collections;
    import java.util.Collection;
    class Test {
        public static void main(String [] argv){
            Properties p=new Properties();
            for (String s : Collections.list(p.propertyNames())){
                System.out.println(s);
    }I have tried casting the ArrayList result, and the passed in Enumeration.
    Christopher
    P.S. What does the first <T> mean in the declaration of Collections.list?
    public static <T> ArrayList<T> list(Enumeration<T> e)

    I'm pretty sure you can't. Let's gradually expand your code, filling in local variables so you can see why:
    for (String s : Collections.list(p.propertyNames()))becomes
    List<String> list = Collections.list(p.propertyNames()); // not typesafe
    for (String s : list)So why isn't that list typesafe? Well, let's keep going.
    Enumeration<String> enumeration = p.propertyNames(); // not typesafe
    List<String> list = Collections.list(enumeration);
    for (String s : list)The problem is that the method p.propertyNames() does not return an Enumeration<String>; it returns an Enumeration<?>. That's where your type safety problem shows up.
    You will notice that the Properties object extends Hashtable<Object,Object>. This means that it's entirely possible that the Properties object contains a non-String key.
    An ugly solution might be something like this:
    List<String> propertyNames = new ArrayList<String>();
    for (Object o : p.propertyNames()) propertyNames.add(o.toString());
    for (String s : propertyNames) ...Obviously, this won't work the same way if the Properties object contains a non-String key... but if you're willing to assume it doesn't, that solution should be fine.
    Cheers!

  • How to use object collection with linked objects

    <p>Hi,</p><p>I&#39;m using VS2005 Crystal reports in a c# client app (server has database, but client does not have!). So the use of the objects transfered to the client seemed to me a good solution for showing reports on the client. The objects mostly link to several other objects (properties of type <type> or properties of type [] <type>) and the links are correctly configured in database assistant.</p><p>But: Whenever using one of the linked fields, all of the main fields will never show up in the report.</p><p>So, what is the correct way of showing a master / detail report using linked object collections???</p><p> (A small test sample app can be provided upon request)</p><p> TIA</p><p>BP</p>

    What database and connection type are you using? Are you connecting the report directly to the database, or trying to assign the datasource to object data?
    It sounds like you might be trying to use a linked list, collection or other C# construct to pass your data in. This currently isn't supported by the Crystal Reports SDK. You can use a DataSet or a DataTable, and possibly also an IDataReader depending on which version of Crystal Reports you're referencing in your project. Of course you can also connect directly to the database, even if the database isn't on the same machine as the application.
    The way to show master records with detail information is through the use of subreports and linked subreport parameters. Linked subreports take their parameter value from a record in the main report, so that only the data appropriate to that master record is displayed. The guys over in the [report design|SAP Crystal Reports; forum can help you out with this if you have questions on the specifics.

  • Linked lists problem -- help needed

    Hello again. I've got yet another problem in my C++ course that stems from my use of a Mac instead of Windows. I'm going to install Parallels so I can get Windows on my MacBook and install Visual Studio this week so that I don't have to deal with these discrepancies anymore, but in the meanwhile, I'm having a problem here that I don't know how to resolve. To be clear, I've spent a lot of time trying to work this out myself, so I'm not just throwing this up here to have you guys do the work for me -- I'm really stuck here, and am coming here as a last resort, so I'll be very, very appreciative for any help that anyone can offer.
    In my C++ course, we are on a chapter about linked lists, and the professor has given us a template to make the linked lists work. It comes in three files (a header, a source file, and a main source file). I've made some adjustments -- the original files the professor provided brought up 36 errors and a handful of warnings, but I altered the #include directives and got it down to 2 errors. The problematic part of the code (the part that contains the two errors) is in one of the function definitions, print_list(), in the source file. That function definition is shown below, and I've marked the two statements that have the errors using comments that say exactly what the errors say in my Xcode window under those two statements. If you want to see the entire template, I've pasted the full code from all three files at the bottom of this post, but for now, here is the function definition (in the source file) that contains the part of the code with the errors:
    void LinkedList::printlist( )
    // good for only a few nodes in a list
    if(isEmpty() == 1)
    cout << "No nodes to display" << endl;
    return;
    for(CURSOR = FRONT_ptr; CURSOR; CURSOR = CURSOR-> link)
    { cout << setw(8) << CURSOR->name; } cout << endl; // error: 'setw' was not declared in this scope
    for(CURSOR = FRONT_ptr; CURSOR; CURSOR = CURSOR-> link)
    { cout << setw(8) << CURSOR->test_grade; } cout << endl; // error: 'setw' was not declared in this scope
    As you can see, the problem is with the two statements that contain the 'setw' function. Can anyone help me figure out how to get this template working and get by these two errors? I don't know enough about linked lists to know what I can and can't mess with here to get it working. The professor recommended that I try using 'printf' instead of 'cout' for those two statements, but I don't know how to achieve the same effect (how to do whatever 'setw' does) using 'printf'. Can anyone please help me get this template working? Thank you very, very much.
    For reference, here is the full code from all three files that make up the template:
    linkedlist.h (header file):
    #ifndef LINKED_LINKED_H
    #define LINKED_LINKED_H
    struct NODE
    string name;
    int test_grade;
    NODE * link;
    class Linked_List
    public:
    Linked_List();
    void insert(string n, int score);
    void remove(string target);
    void print_list();
    private:
    bool isEmpty();
    NODE *FRONT_ptr, *REAR_ptr, *CURSOR, *INSERT, *PREVIOUS_ptr;
    #endif
    linkedlist.cpp (source file):
    #include <iostream>
    using namespace std;
    #include "linkedlist.h"
    LinkedList::LinkedList()
    FRONT_ptr = NULL;
    REAR_ptr = NULL;
    PREVIOUS_ptr = NULL;
    CURSOR = NULL;
    void Linked_List::insert(string n, int score)
    INSERT = new NODE;
    if(isEmpty()) // first item in List
    // collect information into INSERT NODE
    INSERT-> name = n;
    // must use strcpy to assign strings
    INSERT -> test_grade = score;
    INSERT -> link = NULL;
    FRONT_ptr = INSERT;
    REAR_ptr = INSERT;
    else // else what?? When would this happen??
    // collect information into INSERT NODE
    INSERT-> name = n; // must use strcpy to assign strings
    INSERT -> test_grade = score;
    REAR_ptr -> link = INSERT;
    INSERT -> link = NULL;
    REAR_ptr = INSERT;
    void LinkedList::printlist( )
    // good for only a few nodes in a list
    if(isEmpty() == 1)
    cout << "No nodes to display" << endl;
    return;
    for(CURSOR = FRONT_ptr; CURSOR; CURSOR = CURSOR-> link)
    { cout << setw(8) << CURSOR->name; } cout << endl; // error: 'setw' was not declared in this scope
    for(CURSOR = FRONT_ptr; CURSOR; CURSOR = CURSOR-> link)
    { cout << setw(8) << CURSOR->test_grade; } cout << endl; // error: 'setw' was not declared in this scope
    void Linked_List::remove(string target)
    // 3 possible places that NODES can be removed from in the Linked List
    // FRONT
    // MIDDLE
    // REAR
    // all 3 condition need to be covered and coded
    // use Trasversing to find TARGET
    PREVIOUS_ptr = NULL;
    for(CURSOR = FRONT_ptr; CURSOR; CURSOR = CURSOR-> link)
    if(CURSOR->name == target) // match
    { break; } // function will still continue, CURSOR will
    // mark NODE to be removed
    else
    { PREVIOUS_ptr = CURSOR; } // PREVIOUS marks what NODE CURSOR is marking
    // JUST before CURSOR is about to move to the next NODE
    if(CURSOR == NULL) // never found a match
    { return; }
    else
    // check each condition FRONT, REAR and MIDDLE
    if(CURSOR == FRONT_ptr)
    // TARGET node was the first in the list
    FRONT_ptr = FRONT_ptr -> link; // moves FRONT_ptr up one node
    delete CURSOR; // deletes and return NODE back to free memory!!!
    return;
    }// why no need for PREVIOUS??
    else if (CURSOR == REAR_ptr) // TARGET node was the last in the list
    { // will need PREVIOUS for this one
    PREVIOUS_ptr -> link = NULL; // since this node will become the last in the list
    REAR_ptr = PREVIOUS_ptr; // = REAR_ptr; // moves REAR_ptr into correct position in list
    delete CURSOR; // deletes and return NODE back to free memory!!!
    return;
    else // TARGET node was the middle of the list
    { // will need PREVIOUS also for this one
    PREVIOUS_ptr -> link = CURSOR-> link; // moves PREV nodes' link to point where CURSOR nodes' points
    delete CURSOR; // deletes and return NODE back to free memory!!!
    return;
    bool Linked_List::isEmpty()
    if ((FRONT_ptr == NULL) && (REAR_ptr == NULL))
    { return true; }
    else
    { return false;}
    llmain.cpp (main source file):
    #include <iostream>
    #include <string>
    #include <iomanip>
    using namespace std;
    #include "linkedlist.h"
    int main()
    Linked_List one;
    one.insert("Angela", 261);
    one.insert("Jack", 20);
    one.insert("Peter", 120);
    one.insert("Chris", 270);
    one.print_list();
    one.remove("Jack");
    one.print_list();
    one.remove("Angela");
    one.print_list();
    one.remove("Chris");
    one.print_list();
    return 0;

    setw is the equivalent of the field width value in printf. In your code, the printf version would look like:
    printf("%8s", CURSOR->name.c_str());
    I much prefer printf over any I/O formatting in C++. See the printf man page for more information. I recommend using Bwana: http://www.bruji.com/bwana/
    I do think it is a good idea to verify your code on the platform it will be tested against. That means Visual Studio. However, you don't want to use Visual Studio. As you have found out, it gets people into too many bad habits. Linux is much the same way. Both development platforms are designed to build anything, whether or not it is syntactically correct. Both GNU and Microsoft have a long history of changing the language standards just to suit themselves.
    I don't know what level you are in the class, but I have a few tips for you. I'll phrase them so that they answers are a good exercise for the student
    * Look into const-correctness.
    * You don't need to compare a bool to 1. You can just use bool. Plus, any integer or pointer type has an implicit cast to bool.
    * Don't reuse your CURSOR pointer as a temporary index. Create a new pointer inside the for loop.
    * In C++, a struct is the same thing as a class, with all of its members public by default. You can create constructors and member functions in a struct.
    * Optimize your function arguments. Pass by const reference instead of by copy. You will need to use pass by copy at a later date, but don't worry about that now.
    * Look into initializer lists.
    * In C++ NULL and 0 are always the same.
    * Return the result of an expression instead of true or false. Technically this isn't officially Return Value Optimization, but it is a good habit.
    Of course, get it running first, then make it fancy.

  • Which is better ListIterator or Simple list.size() in for loop

    Hi everybody
    I have one scenario in which, I need to delete the duplicate values from the list (Note : Duplicate values are coming in sequence).
    I tried to approaches as follows
    1) Using ListIterator
    I iterated all values and if I found any duplicate then I called remove() method of Iterator.
    2) I made another ArrrayList object, and iterated the old list using size() and for loop, and if I found unique value then I added that value to the new ArrayList.
    I also created one test java file to find out the performance in both cases. But I am not pretty sure that this test is correct or not. Please suggest me which approach is correct.
    code For Test
    public class TestReadonly {
         public static void main(String[] args) {
              List list = new ArrayList();
              long beforeHeap = 0,afterHeap = 0;
              long beforeTime = 0,afterTime = 0;
              addElementsToList(list);
              Collections.sort(list);
              callGC();
              beforeHeap = Runtime.getRuntime().freeMemory();
              beforeTime = System.currentTimeMillis();
              System.out.println(" Before "+System.currentTimeMillis()+" List Size "+list.size()+" heap Size "+beforeHeap);
              new TestReadonly().deleteDuplicated1(list);
              afterHeap = Runtime.getRuntime().freeMemory();
              afterTime = System.currentTimeMillis();
              System.out.println(" After  "+System.currentTimeMillis()+" List Size "+list.size()+" heap Size "+afterHeap);
              System.out.println(" Time Differance "+(afterTime-beforeTime)+" Heap Differance "+(afterHeap-beforeHeap));
              list.clear();
              addElementsToList(list);
              Collections.sort(list);
              callGC();
              beforeHeap = Runtime.getRuntime().freeMemory();
              beforeTime = System.currentTimeMillis();
              System.out.println(" Before "+System.currentTimeMillis()+" List Size "+list.size()+" heap Size "+beforeHeap);
              list = new TestReadonly().deleteDuplicated2(list);
              afterHeap = Runtime.getRuntime().freeMemory();
              afterTime = System.currentTimeMillis();
              System.out.println(" After  "+System.currentTimeMillis()+" List Size "+list.size()+" heap Size "+afterHeap);
              System.out.println(" Time Differance "+(afterTime-beforeTime)+" Heap Differance "+(afterHeap-beforeHeap));
          * @param list
         private static void addElementsToList(List list) {
              for(int i=0;i<1000000;i++) {
                   list.add("List Object"+i);
              for(int i=0;i<10000;i++) {
                   list.add("List Object"+i);
         private static void callGC() {
              Runtime.getRuntime().gc();
              Runtime.getRuntime().gc();
              Runtime.getRuntime().gc();
              Runtime.getRuntime().gc();
              Runtime.getRuntime().gc();
         private void deleteDuplicated1(List employeeList) {
              String BLANK = "";
              String currentEmployeeNumber = null;
              String previousEmployeeNumber = null;
              ListIterator iterator = employeeList.listIterator();
              while (iterator.hasNext()) {
                   previousEmployeeNumber = currentEmployeeNumber;
                   currentEmployeeNumber = (String) iterator.next();
                   if ((currentEmployeeNumber.equals(previousEmployeeNumber))
                             || ((BLANK.equals(currentEmployeeNumber) && BLANK
                                       .equals(previousEmployeeNumber)))) {
                        iterator.remove();
         private List deleteDuplicated2(List employeeList) {
              String BLANK = "";
              String currentEmployeeNumber = null;
              String previousEmployeeNumber = null;
              List l1 = new ArrayList(employeeList.size());
              for (int i =0;i<employeeList.size();i++) {
                   previousEmployeeNumber = currentEmployeeNumber;
                   currentEmployeeNumber = (String) employeeList.get(i);
                   if (!(currentEmployeeNumber.equals(previousEmployeeNumber))
                             || ((BLANK.equals(currentEmployeeNumber) && BLANK
                                       .equals(previousEmployeeNumber)))) {
                        l1.add(currentEmployeeNumber);
              return l1;
    Output
    Before 1179384331873 List Size 1010000 heap Size 60739664
    After 1179384365545 List Size 1000000 heap Size 60737600
    Time Differance 33672 Heap Differance -2064
    Before 1179384367545 List Size 1010000 heap Size 60739584
    After 1179384367639 List Size 1000000 heap Size 56697504
    Time Differance 94 Heap Differance -4042080

    I think, you test is ok like that. Although I would have tested with two different applications, just to be shure that the heap is clean. You never know what gc() actually does.
    Still, your results show what is expected:
    Approach 1 (List iterator) takes virtually no extra memory, but takes a lot of time, since the list has to be rebuild after each remove.
    Approach 2 is much faster, but takes a lot of extra memory, since you need a "copy" of the original list.
    Basically, both approaches are valid. You have to decide depending on your requirements.
    Approach 1 can be optimized by using a LinkedList instead of an ArrayList. When you remove an element from an ArrayList, all following elements have to be shifted which takes a lot of time. A LinkedList should behave better.
    Finally, instead of searching for duplicates, consider to check for duplicates when filling the list or even use a Map.
    Tobias

  • MRP Date in MRP List

    Hello All,
    While accessing the MRP List (collective access MD06). There is a selection option for MRP Date. SAP Help tells that "Date: for example, all MRP lists that were created or processed within the last two weeks".
    But I could not understand what this means. Please clarify this.
    Regards
    Mahesh

    Hi
    It means that, the MRP list will be displayed only for those materials that were created in that time frame. There might be materials for which MRP is not run and processed within that time frame. they will not be displayed. This is one of the parameters for filtering the list.
    Hope this is clear and helpful. If so please reward
    Chandra

Maybe you are looking for

  • How can I use my hotmail on an Iphone

    What kind of system is hotmail is it an IMAP? I'm using my hotmail the most so I would like to know how can I use hotmail on an Iphone.

  • How can i do a proper calculation of working hours?

    I have tried doing a calculation of my working hours using the ABS formula but it still gives me the wrong answer. 5:00 PM 1:00 AM 16h the formula is =ABS(A1-A2) the resulte shoulb be 8h but it shows 16h....

  • Import of RAW (NEF) files from Nikon D 90

    Hi there: > I am new to lightroom and just got a 30 days trial version. I desperately try to import directly RAW (NEF) files into lightroom 2. I have downloaded Adobes latest RAW converter. I also checked all available support areas (hope at least I

  • E6-00 -- How to Hide Clock & "Active Profile'

    Hi I want my E6-00 Home screen NOT to show the irritating Clock & "Active Profile" on ALL Home Screens. I want them to be added / removed on the Home screens like any other widgets.

  • Inconsistent amounts

    Hi, While converting parking invoice to invoice I get the following error: Inconsistent amounts Message no. F5704 Diagnosis Item "0000000001" in the FI/CO document has the debit/credit indicator "H". Amounts in the FI/CO interface are assigned a +/-