1

I'm trying to check to remove from a List given that the list contains certain String element in it. Here is what I have:

List<String> list //this list contains 3 String elements, "a", "b", and "c"


if (list.contains("a") && list.contains("b"))
    {
        list.remove("a");
    }

But when it runs to the if statement I got a source not found error from Eclipse debugger. Does anyone have a better idea as to why this is happening? The list is using java.util.List

user974047
  • 2,115
  • 7
  • 33
  • 45
  • 1
    what error are you getting? are you iterating on the List? – Massimiliano Peluso Jun 10 '13 at 15:39
  • 1
    http://stackoverflow.com/questions/6174550/eclipse-java-debugging-source-not-found – Alexis C. Jun 10 '13 at 15:39
  • If you don't want to debug it, then split the if condition to: `if (list.contains("a")) list.remove("a"); else if (list.contains("b")) list.remove("b"); – darijan Jun 10 '13 at 15:41
  • The `remove` method in List won't throw an Exception if you call it but the element isn't present in the List. So technically you don't need to call `contains` at all (unless you're checking that the list contains an element other than the one you're deleting.) – Roddy of the Frozen Peas Jun 10 '13 at 15:47

3 Answers3

3

The source not found means that you're trying to step into the code of a class but you don't have the source code for that class. It is not related to your code, but to your project configuration.

WilQu
  • 7,131
  • 6
  • 30
  • 38
0

It seems your file is not being compiled in eclipse.

Check Build Automatically option under Project menu option in eclipse and refresh.

Or hit Clean... under Project menu option

Kalher
  • 3,613
  • 2
  • 24
  • 34
0

This is not an error in your code. You can not see the code inside the debugger, because you only got the compiled bytecode in your project. At this point, you're calling a method from a class, where you don't have the original source code, just the compiled bytecode at all. If you find the sourcecode itself, you can attach it to your project and link it to them.

BTW: Your question was answered before, as ZouZou said in the comments.

Community
  • 1
  • 1
Martin Seeler
  • 6,874
  • 3
  • 33
  • 45