Results 1 to 8 of 8

Thread: Core Java

  1. #1
    Join Date
    Jun 2010
    Posts
    25
    Rep Power
    0

    Post Core Java

    List<CommercialDTO> commList = new ArrayList<CommercialDTO>();
    commList = model.getCommercialList();
    System.out.println("ListDataRows Count ::::::"+ commList.size());
    Iterator<CommercialDTO> it = commList.iterator();
    CommercialDTO commDTO = null;
    while (it.hasNext()) {
    commDTO = it.next();
    int i = 0;
    for (CommercialDTO goodsDTO : commList) {
    if(commDTO.getCommName().equalsIgnoreCase(goodsDTO .getCommName())) {
    if (i >= 1) {
    messageList.clear();
    System.out.println("===both are equal===");
    em.setKey("customs.tariff.message.error.DUPLICATE_ ENTRY");
    em.setParamList(new String[] { "r:customs.tariff.commercialName",goodsDTO.getComm Name() });
    em.setComponentId("hsCodeCreateForm:hsCodeError");
    messageList.add(em);
    }

    i++;
    }
    }
    }
    System.out.println("returning error message list value:"
    + messageList.size());

    return messageList;



    hi i have list of values i am trying to find the duplicate by using criteria(name)

    can you check this and let me know.or is there any other alternative to find duplicates in the list.

    Thanks
    Muralikrishna
    Thanks&Regards,
    Muralikrishna K

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Use a Set.

  3. #3
    Join Date
    Jun 2010
    Posts
    25
    Rep Power
    0

    Post

    can you send me the code once
    Thanks&Regards,
    Muralikrishna K

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Read the Java API.

  5. #5
    Join Date
    Jun 2010
    Posts
    25
    Rep Power
    0

    Default

    i know to read API but u tell me the code.i posted my code na
    Thanks&Regards,
    Muralikrishna K

  6. #6
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Yeah right. I'm not spoonfeeding you.

  7. #7
    Join Date
    Jun 2010
    Posts
    25
    Rep Power
    0

    Default

    thanks.what i posted the code is right or wrong.
    Thanks&Regards,
    Muralikrishna K

  8. #8
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Quote Originally Posted by murali23krishna View Post
    i know to read API but u tell me the code.i posted my code na
    Come on Murali. Don't be childish. :p

    What's tough in that? Create a Hashset and pass your ArrayList to it's constructor. This Set now removes the duplicate values as it's not allowed in it.

    Then clear you ArrayList and use the addAll method to add the HashSet back to the ArrayList. Simple.

    See the API documentation for the clear() and addAll(Collection c) methods.

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

Similar Threads

  1. Whats next after core java
    By nn12 in forum Advanced Java
    Replies: 7
    Last Post: 10-11-2013, 08:59 AM
  2. After getting knowledge core java...
    By spk2712 in forum New To Java
    Replies: 2
    Last Post: 01-23-2011, 11:14 AM
  3. query on core java
    By venkatallu in forum New To Java
    Replies: 1
    Last Post: 09-01-2008, 02:23 PM
  4. Core Java Vs. J2EE
    By evanp in forum New To Java
    Replies: 2
    Last Post: 07-23-2008, 01:27 PM
  5. A core java Question
    By chravikumar008 in forum New To Java
    Replies: 2
    Last Post: 04-21-2008, 08:04 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •