if(count == 4){
		qFinal.enqueue(q.peek());
		if(count3 == 0){
		System.out.println(qFinal);
		break;
	       }	
		else{			
		    sort(qFinal);
		}		
	}

this code is inside a while loop, and with the break statement, it should break out of the loop right? instead i think the program also executes the sort(qFinal) method b/c after it prints qFinal correctly, the program gives me an error.

Edited 5 Years Ago by plasticfood: n/a

Okay? So it gives you an error? And? How did you determine that this sort method had anything to do with it, or are you just guessing? Print the stacktrace of the error and read it. It will tell you exactly where the problem is. If you find yourself incapable of zeroeing in on the problem this way, then post the full stack trace here and more code, that little snippet above tells us nothing.

after if and before else? you mean like this?

if ( valid ){
  // code if valid
}
break;
else{
  // code if not valid
}

looks to me like you're setting yourself up to get two problems..
1. you'll run the break no mather whether valid is true or not
2. I kind of think you'll run into an 'else without an if' error

Huh? Try again. Doing that would, of course, lead to an "else without if" compiler message. Please, don't guess, or at least try your guesses before posting them.

Edit: Damn! Too slow, again!

Edited 5 Years Ago by masijade: n/a

This question has already been answered. Start a new discussion instead.