Results 1 to 8 of 8
Thread: Core Java
- 02-25-2011, 05:29 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 25
- Rep Power
- 0
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
MuralikrishnaThanks&Regards,
Muralikrishna K
- 02-25-2011, 05:39 AM #2
Use a Set.
- 02-25-2011, 05:41 AM #3
Member
- Join Date
- Jun 2010
- Posts
- 25
- Rep Power
- 0
can you send me the code once
Thanks&Regards,
Muralikrishna K
- 02-25-2011, 05:47 AM #4
Read the Java API.
- 02-25-2011, 05:50 AM #5
Member
- Join Date
- Jun 2010
- Posts
- 25
- Rep Power
- 0
i know to read API but u tell me the code.i posted my code na
Thanks&Regards,
Muralikrishna K
- 02-25-2011, 05:52 AM #6
Yeah right. I'm not spoonfeeding you.
- 02-25-2011, 05:53 AM #7
Member
- Join Date
- Jun 2010
- Posts
- 25
- Rep Power
- 0
thanks.what i posted the code is right or wrong.
Thanks&Regards,
Muralikrishna K
- 02-25-2011, 05:56 AM #8
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.
GoldestJava Is A Funny Language... Really!.gif)
Click on * and add to member reputation, if you find their advices/solutions effective.
Similar Threads
-
After getting knowledge core java...
By spk2712 in forum New To JavaReplies: 2Last Post: 01-23-2011, 11:14 AM -
Whats next after core java
By nn12 in forum Advanced JavaReplies: 4Last Post: 09-23-2008, 01:07 PM -
query on core java
By venkatallu in forum New To JavaReplies: 1Last Post: 09-01-2008, 02:23 PM -
Core Java Vs. J2EE
By evanp in forum New To JavaReplies: 2Last Post: 07-23-2008, 01:27 PM -
A core java Question
By chravikumar008 in forum New To JavaReplies: 2Last Post: 04-21-2008, 08:04 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks