if (usrPass.length() >= 6) {
	for (int i = 0; i < usrPass.length(); i++) {
		passCh = usrPass.charAt(i);
		if (passCh == ' ') {
		            b = true;   //Bad
		            System.out.println("got a space at" +i);
		if (Character.isUpperCase(passCh))
		            c = true;           //Good
		if (Character.isLowerCase(passCh))
			d = true;	//Good
		if (Character.isDigit(passCh))
			e = true;	//Good		

This is a sample of a loop im running, usrPass is sent in from a keyboard input.

Problem i'm having is it works perfect if the white space is in the middle but if its leading or trailing the string its ignored. so
" x aa "
it would only start counting/finding them after the x and stop after the last a.

The snippet as such doesn't seem to reek of any bugs so your best bet would be to look at the place where usrPass actually originates. Maybe it's the way you are accepting user input which is causing it to trim whitespaces.

One minor point; instead of passCh == ' ' , consider using Character.isWhitespace(passCh) since a space is not the only whitespace out there unless you are only checking for spaces.

Ah ye thanks,

I was using the formentioned statement for a while but was trying everything to fix it.
Think you've lead to the problem so thanks

This is part of a supplied input module
seems it uses trim... this is where usrPass is from.
Guess ill just have to discuss the situation with my uni.

public static String getString()
     boolean ok = false;
           bytesRead = System.in.read(b);
           s = new String(b,0,bytesRead-1);
           ok = true;
        catch(IOException e)
	return s;
This article has been dead for over six months. Start a new discussion instead.