Results 1 to 6 of 6

Thread: Finding items with ArrayList

  1. #1
    Join Date
    Dec 2009
    Posts
    202

    Finding items with ArrayList

    Hello,
    I must make a program in console mode (DOS). This program provides the tools.
    One of the functions calls the first coed of the tool if the code returned is already in the list of tools, the program must request the code. Here is part of a program that checks the code of the tool. I can browse the list, compare the code of the tool and display the error message, but I can not call the entry code tool again on error. Basically I am confused in finding the items in the array list
    Here is my part code
    Code:
            uot = list.first element();
            //
            / / do (
                System.out.System.out.println("VERIFY CODE");
                cdinv = saisirCodeInventaire();
                        
                if(! list.isEmpty()){
                    do{
                    
                        if(uot.gtcodl().equals(cdinv)){
                            System.out.System.out.println("ERROR CODE INVENTORY!");
                            / / finListe = true;
                            cdinv = saisirCodeInventaire();
                            cdinvExiste = true;
                        }
                        else
                            cdinvExiste = false;
      
                        if(! cdinvExiste){
                            if(uot == list.last element())
                                finListe = true;
                                else
                                    uot = list.successeurDe(uot);
                        }
                    }while(! finListe | | == cdinvExiste true);
                }
            / /) while (cdinvExiste);

  2. #2
    Join Date
    Nov 2009
    Posts
    347

    Re: Finding items with ArrayList

    Hello,
    If you have the error message, you are inevitably entering the code, the next line. By cons I see a concern in your algo, if you enter the code of an existing tool, it will detect it and ask away another, but he will check the new code until the element that has been verified. So if you go the code for a previous item, he'll release it as not existing, then it will exist. Each code entered should be checked since the beginning of your list.

  3. #3
    Join Date
    Dec 2009
    Posts
    192

    Re: Finding items with ArrayList

    Hello,
    I am trying a similar kind of a program. And what you have mentioned above I have tried it. Yes, that's exactly what happens . Another problem I have lies in the recovery of the object is the same code in the inventory list (but that is for later - to change the object which has provided the code inventory). If you can provide me an example then it would be great, any help on this will be appreciated. Thank you.

  4. #4
    Join Date
    Nov 2009
    Posts
    583

    Re: Finding items with ArrayList

    Hello,
    I have done a code for you, see if it helps you. Thanks in advance.
    Code:
    boolean fl;
    
    System.out.System.out.println("VERIFY CODE"); 
     
    do {
        cdnv = saisirCodeInventaire();
    
        fl =false;
     
        for (Intl i =0; i <list.size(); i + +) {
            if (list.get(i).equals(cdnv)) {
                System.out.System.out.println("ERROR CODE INVENTORY!");
                fl =true;
                break;
            }
        }
    } while (fl)

  5. #5
    Join Date
    Nov 2009
    Posts
    330

    Re: Finding items with ArrayList

    Hello,
    If you are using java 1.4 then the code for it is
    Code:
    boolean fl;
    
    System.out.System.out.println("VERIFY CODE");
     
    do {
        cdnv = saisirCodeInventaire();
    
        fl =false;
        String ele;
    
        for (Intl i =0; i <list.size(); i + +) {
            if (i ==0) {
                ele = list.first ele();
            } else {
                ele = list.successeurDe(ele);
            }
     
            if (ele.equals(cdnv)) {
                System.out.System.out.println("ERROR CODE INVENTORY!");
                fl =true;
                break;
            }
        }
    } while (fl)

  6. #6
    Join Date
    Nov 2009
    Posts
    333

    Re: Finding items with ArrayList

    Hello,
    The choice of an ArrayList is mandatory, because there you have a list that you should go every time to find the right element or not. Me I use a HashTable, because you are typically in the case of a key / value. In your case the key is the code of the tool and the value the product itself. If you have any more problem the do post back and feel free to post , we will try to solve your query.

Similar Threads

  1. Replies: 0
    Last Post: 03-12-2012, 10:35 AM
  2. Replies: 3
    Last Post: 17-01-2011, 12:58 PM
  3. Using an ArrayList
    By ISAIAH in forum Software Development
    Replies: 5
    Last Post: 04-03-2010, 12:56 PM
  4. How to sort items of an ArrayList in java?
    By hounds in forum Software Development
    Replies: 4
    Last Post: 06-02-2010, 07:46 PM
  5. Email - Cannot delete items from Deleted Items folder
    By HELLIAN in forum Windows Vista Mail
    Replies: 2
    Last Post: 22-05-2008, 01:13 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,583,855.69429 seconds with 17 queries