0
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 by plasticfood: n/a

4
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by masijade
0

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.

0

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

0

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 by masijade: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.