在我的應用程序應該從列表中的線程上運行時刪除一個字符串,但我得到異常 一樣,刪除字符串
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: item gh not found in list
at java.awt.List.remove(Unknown Source)
at org.sample.ChatClient$updateClient$1.run(ChatClient.java:200)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
代碼:
final Map<String, String> liHashMap=list;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (Entry<String, String> entry : liHashMap.entrySet()) {
String client_Name=entry.getKey();
if(!checkList.containsKey(client_Name)) {
lst.add(client_Name + "\n");
checkList.put(client_Name, ipAddress);
}
}
for (Entry<String, String> entry : checkList.entrySet()) {
String client_Name=entry.getKey();
if(!liHashMap.containsKey(client_Name)){
lst.remove(client_Name);//Remove string from list
checkList.remove(client_Name);
}
}
'java.lang.IllegalArgumentException:在列表中找不到gh項目如果該項目存在,是否檢入了代碼?我認爲這個錯誤很明顯。此外,您應該需要上傳「串」到您的列表(代碼)的位置和方式。 – DaGLiMiOuX 2013-05-08 14:03:20