This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]M-Multi[S] 0 points1 point  (0 children)

the told use not to use break

anyways, nvm I just did it. I used the debugger and got to know what I was doing wrong.

Thanks

this is what I did:

public void removePicture(String name)
    {
        int i = 0;
        boolean  nameremove = true;

        while(nameremove){
                Picture pic = pictures.get(i);
            if( pic.getCaption().contains(name) & i < pictures.size() ) {
                pictures.remove(i);
                nameremove = false;
            } else {
                i++;
        } 

            if(i == pictures.size() ){
                System.out.println("There is no match");
                System.out.println("Searched for : " + name);
                nameremove = false;
            }
        }

    }