How do i iterate through two different arrays?

siddharthkool
siddharthkool used Ask the Experts™
on
if i try to iterate through one array it works fine but when i try to iterate through second it prints only first array element.
Please find the attachment
sample.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
You should probably do something more like the following, or you're skipping an element
       while (iterator.hasNext()) {
	    String findMe = iterator.next();
            if (dirSearch(dir, findMe) != -1) {
                System.out.println("Dir Match found: " + dir[i]);
            }
            else if (subdirSearch(subdir, findMe) != -1) {
                System.out.println("SubDir Match found: " + subdir[i]);
            }
        }

Open in new window

Java Developer
Top Expert 2010
Commented:
  while (iterator.hasNext()){
        String next = iterator.next().toString()
        if(dirSearch(dir, next) != -1)
        {
           System.out.println("Dir Match found: "+dir[i]);
        }
        else if(subdirSearch(subdir, next) != -1)
        {
           System.out.println("SubDir Match found: "+subdir[i]);
        }
    }

Author

Commented:
issue solved
Top Expert 2016

Commented:
siddharthkool: can you explain why you accepted an answer that's a copy of one i'd already posted?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial